splent-cli 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. splent_cli-0.0.1/LICENSE +113 -0
  2. splent_cli-0.0.1/PKG-INFO +133 -0
  3. splent_cli-0.0.1/README.md +1 -0
  4. splent_cli-0.0.1/pyproject.toml +35 -0
  5. splent_cli-0.0.1/setup.cfg +4 -0
  6. splent_cli-0.0.1/splent_cli/__init__.py +6 -0
  7. splent_cli-0.0.1/splent_cli/__main__.py +11 -0
  8. splent_cli-0.0.1/splent_cli/cli.py +59 -0
  9. splent_cli-0.0.1/splent_cli/commands/__init__.py +0 -0
  10. splent_cli-0.0.1/splent_cli/commands/clear_cache.py +90 -0
  11. splent_cli-0.0.1/splent_cli/commands/clear_log.py +31 -0
  12. splent_cli-0.0.1/splent_cli/commands/clear_uploads.py +44 -0
  13. splent_cli-0.0.1/splent_cli/commands/compose_env.py +50 -0
  14. splent_cli-0.0.1/splent_cli/commands/coverage.py +46 -0
  15. splent_cli-0.0.1/splent_cli/commands/db_console.py +27 -0
  16. splent_cli-0.0.1/splent_cli/commands/db_dump.py +45 -0
  17. splent_cli-0.0.1/splent_cli/commands/db_migrate.py +37 -0
  18. splent_cli-0.0.1/splent_cli/commands/db_reset.py +90 -0
  19. splent_cli-0.0.1/splent_cli/commands/db_seed.py +123 -0
  20. splent_cli-0.0.1/splent_cli/commands/env.py +18 -0
  21. splent_cli-0.0.1/splent_cli/commands/info.py +74 -0
  22. splent_cli-0.0.1/splent_cli/commands/linter.py +146 -0
  23. splent_cli-0.0.1/splent_cli/commands/locust.py +219 -0
  24. splent_cli-0.0.1/splent_cli/commands/module_create.py +138 -0
  25. splent_cli-0.0.1/splent_cli/commands/module_list.py +28 -0
  26. splent_cli-0.0.1/splent_cli/commands/route_list.py +68 -0
  27. splent_cli-0.0.1/splent_cli/commands/selenium.py +85 -0
  28. splent_cli-0.0.1/splent_cli/commands/test.py +45 -0
  29. splent_cli-0.0.1/splent_cli/commands/update.py +159 -0
  30. splent_cli-0.0.1/splent_cli/commands/webpack_compile.py +68 -0
  31. splent_cli-0.0.1/splent_cli/utils/__init__.py +0 -0
  32. splent_cli-0.0.1/splent_cli/utils/path_utils.py +116 -0
  33. splent_cli-0.0.1/splent_cli.egg-info/PKG-INFO +133 -0
  34. splent_cli-0.0.1/splent_cli.egg-info/SOURCES.txt +36 -0
  35. splent_cli-0.0.1/splent_cli.egg-info/dependency_links.txt +1 -0
  36. splent_cli-0.0.1/splent_cli.egg-info/entry_points.txt +2 -0
  37. splent_cli-0.0.1/splent_cli.egg-info/requires.txt +7 -0
  38. splent_cli-0.0.1/splent_cli.egg-info/top_level.txt +1 -0
@@ -0,0 +1,113 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc.
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of protecting
53
+ users' freedom to change the software. The systematic pattern of such
54
+ abuse occurs in the area of products for individuals to use, which is
55
+ precisely where it is most unacceptable. Therefore, we have designed
56
+ this version of the GPL to prohibit the practice for those products. If
57
+ such problems arise substantially in other domains, we stand ready to
58
+ extend this provision to those domains in future versions of the GPL, as
59
+ needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds
78
+ of works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ (El texto completo es largo, puedes encontrarlo en https://www.gnu.org/licenses/gpl-3.0.txt)
113
+
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.2
2
+ Name: splent_cli
3
+ Version: 0.0.1
4
+ Summary: SPLENT-CLI is a CLI to be able to work on your development more easily.
5
+ Author-email: David Romero <drorganvidez@us.es>
6
+ License: GNU GENERAL PUBLIC LICENSE
7
+ Version 3, 29 June 2007
8
+
9
+ Copyright (C) 2007 Free Software Foundation, Inc.
10
+ Everyone is permitted to copy and distribute verbatim copies
11
+ of this license document, but changing it is not allowed.
12
+
13
+ Preamble
14
+
15
+ The GNU General Public License is a free, copyleft license for
16
+ software and other kinds of works.
17
+
18
+ The licenses for most software and other practical works are designed
19
+ to take away your freedom to share and change the works. By contrast,
20
+ the GNU General Public License is intended to guarantee your freedom to
21
+ share and change all versions of a program--to make sure it remains free
22
+ software for all its users. We, the Free Software Foundation, use the
23
+ GNU General Public License for most of our software; it applies also to
24
+ any other work released this way by its authors. You can apply it to
25
+ your programs, too.
26
+
27
+ When we speak of free software, we are referring to freedom, not
28
+ price. Our General Public Licenses are designed to make sure that you
29
+ have the freedom to distribute copies of free software (and charge for
30
+ them if you wish), that you receive source code or can get it if you
31
+ want it, that you can change the software or use pieces of it in new
32
+ free programs, and that you know you can do these things.
33
+
34
+ To protect your rights, we need to prevent others from denying you
35
+ these rights or asking you to surrender the rights. Therefore, you have
36
+ certain responsibilities if you distribute copies of the software, or if
37
+ you modify it: responsibilities to respect the freedom of others.
38
+
39
+ For example, if you distribute copies of such a program, whether
40
+ gratis or for a fee, you must pass on to the recipients the same
41
+ freedoms that you received. You must make sure that they, too, receive
42
+ or can get the source code. And you must show them these terms so they
43
+ know their rights.
44
+
45
+ Developers that use the GNU GPL protect your rights with two steps:
46
+ (1) assert copyright on the software, and (2) offer you this License
47
+ giving you legal permission to copy, distribute and/or modify it.
48
+
49
+ For the developers' and authors' protection, the GPL clearly explains
50
+ that there is no warranty for this free software. For both users' and
51
+ authors' sake, the GPL requires that modified versions be marked as
52
+ changed, so that their problems will not be attributed erroneously to
53
+ authors of previous versions.
54
+
55
+ Some devices are designed to deny users access to install or run
56
+ modified versions of the software inside them, although the manufacturer
57
+ can do so. This is fundamentally incompatible with the aim of protecting
58
+ users' freedom to change the software. The systematic pattern of such
59
+ abuse occurs in the area of products for individuals to use, which is
60
+ precisely where it is most unacceptable. Therefore, we have designed
61
+ this version of the GPL to prohibit the practice for those products. If
62
+ such problems arise substantially in other domains, we stand ready to
63
+ extend this provision to those domains in future versions of the GPL, as
64
+ needed to protect the freedom of users.
65
+
66
+ Finally, every program is threatened constantly by software patents.
67
+ States should not allow patents to restrict development and use of
68
+ software on general-purpose computers, but in those that do, we wish to
69
+ avoid the special danger that patents applied to a free program could
70
+ make it effectively proprietary. To prevent this, the GPL assures that
71
+ patents cannot be used to render the program non-free.
72
+
73
+ The precise terms and conditions for copying, distribution and
74
+ modification follow.
75
+
76
+ TERMS AND CONDITIONS
77
+
78
+ 0. Definitions.
79
+
80
+ "This License" refers to version 3 of the GNU General Public License.
81
+
82
+ "Copyright" also means copyright-like laws that apply to other kinds
83
+ of works, such as semiconductor masks.
84
+
85
+ "The Program" refers to any copyrightable work licensed under this
86
+ License. Each licensee is addressed as "you". "Licensees" and
87
+ "recipients" may be individuals or organizations.
88
+
89
+ To "modify" a work means to copy from or adapt all or part of the work
90
+ in a fashion requiring copyright permission, other than the making of an
91
+ exact copy. The resulting work is called a "modified version" of the
92
+ earlier work or a work "based on" the earlier work.
93
+
94
+ A "covered work" means either the unmodified Program or a work based
95
+ on the Program.
96
+
97
+ To "propagate" a work means to do anything with it that, without
98
+ permission, would make you directly or secondarily liable for
99
+ infringement under applicable copyright law, except executing it on a
100
+ computer or modifying a private copy. Propagation includes copying,
101
+ distribution (with or without modification), making available to the
102
+ public, and in some countries other activities as well.
103
+
104
+ To "convey" a work means any kind of propagation that enables other
105
+ parties to make or receive copies. Mere interaction with a user through
106
+ a computer network, with no transfer of a copy, is not conveying.
107
+
108
+ An interactive user interface displays "Appropriate Legal Notices"
109
+ to the extent that it includes a convenient and prominently visible
110
+ feature that (1) displays an appropriate copyright notice, and (2)
111
+ tells the user that there is no warranty for the work (except to the
112
+ extent that warranties are provided), that licensees may convey the
113
+ work under this License, and how to view a copy of this License. If
114
+ the interface presents a list of user commands or options, such as a
115
+ menu, a prominent item in the list meets this criterion.
116
+
117
+ (El texto completo es largo, puedes encontrarlo en https://www.gnu.org/licenses/gpl-3.0.txt)
118
+
119
+
120
+ Project-URL: Homepage, https://github.com/diverso-lab/splent_cli
121
+ Project-URL: Issues, https://github.com/diverso-lab/splent_cli/issues
122
+ Requires-Python: >=3.12
123
+ Description-Content-Type: text/markdown
124
+ License-File: LICENSE
125
+ Requires-Dist: click
126
+ Requires-Dist: python-dotenv
127
+ Requires-Dist: flask
128
+ Requires-Dist: setuptools
129
+ Requires-Dist: pytest
130
+ Requires-Dist: pytest-cov
131
+ Requires-Dist: ruff
132
+
133
+ # splent_cli
@@ -0,0 +1 @@
1
+ # splent_cli
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "splent_cli"
7
+ version = "0.0.1"
8
+ description = "SPLENT-CLI is a CLI to be able to work on your development more easily."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ authors = [{ name = "David Romero", email = "drorganvidez@us.es" }]
12
+ license = { file = "LICENSE" }
13
+ dependencies = [
14
+ "click",
15
+ "python-dotenv",
16
+ "flask",
17
+ "setuptools",
18
+ "pytest",
19
+ "pytest-cov",
20
+ "ruff"
21
+ ]
22
+
23
+ [tool.black]
24
+ line-length = 79
25
+
26
+ [project.scripts]
27
+ splent_cli = "splent_cli.__main__:main"
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["."]
31
+ include = ["splent_cli*"]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/diverso-lab/splent_cli"
35
+ Issues = "https://github.com/diverso-lab/splent_cli/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ import os
2
+ import sys
3
+
4
+ # Add the project's root directory to the PYTHONPATH
5
+ # This allows Python to locate modules in the parent directory, enabling relative imports.
6
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
@@ -0,0 +1,11 @@
1
+ from splent_cli.cli import check_working_dir, cli, load_commands
2
+
3
+
4
+ def main():
5
+ check_working_dir()
6
+ load_commands(cli)
7
+ cli()
8
+
9
+
10
+ if __name__ == "__main__":
11
+ main()
@@ -0,0 +1,59 @@
1
+ import os
2
+ import sys
3
+ import importlib
4
+ import click
5
+ from dotenv import load_dotenv
6
+ from flask.cli import FlaskGroup # 📌 Añadir FlaskGroup
7
+ from splent_app import create_app # 📌 Importar la app de Flask
8
+
9
+ from splent_cli.utils.path_utils import PathUtils
10
+
11
+ load_dotenv()
12
+
13
+
14
+ def check_working_dir():
15
+ working_dir = os.getenv("WORKING_DIR", "").strip()
16
+
17
+ if not working_dir:
18
+ return
19
+
20
+ if working_dir in ["/app", "/vagrant", "/app/", "/vagrant/"] and not os.path.exists(working_dir):
21
+ print(f"⚠️ WARNING: WORKING_DIR is set to '{working_dir}', but the directory does not exist.")
22
+ sys.exit(1)
23
+
24
+
25
+ class SPLENTCLI(FlaskGroup): # 📌 Usamos FlaskGroup para conectar con Flask
26
+ def __init__(self, **kwargs):
27
+ super().__init__(create_app=create_app, **kwargs)
28
+
29
+ def get_command(self, ctx, cmd_name):
30
+ rv = super().get_command(ctx, cmd_name)
31
+ if rv is None:
32
+ click.echo(f"No such command '{cmd_name}'.")
33
+ click.echo("Try 'splent_cli --help' for a list of available commands.")
34
+ return rv
35
+
36
+
37
+ def load_commands(cli_group, commands_dir="splent_cli/commands"):
38
+ """
39
+ Dynamically import all commands in the specified directory and add them to the CLI group.
40
+ """
41
+ commands_path = PathUtils.get_commands_path()
42
+
43
+ for file in os.listdir(commands_path):
44
+ if file.endswith(".py") and not file.startswith("__"):
45
+ module_name = f"splent_cli.commands.{file[:-3]}"
46
+ module = importlib.import_module(module_name)
47
+ for attr_name in dir(module):
48
+ attr = getattr(module, attr_name)
49
+ if isinstance(attr, click.Command):
50
+ cli_group.add_command(attr)
51
+
52
+
53
+ @click.group(cls=SPLENTCLI)
54
+ def cli():
55
+ """A CLI tool to help with project development."""
56
+
57
+
58
+ if __name__ == "__main__":
59
+ cli()
File without changes
@@ -0,0 +1,90 @@
1
+ from pathlib import Path
2
+
3
+ import click
4
+ import shutil
5
+ import os
6
+
7
+ from splent_cli.utils.path_utils import PathUtils
8
+
9
+
10
+ @click.command(
11
+ "clear:cache",
12
+ help="Clears pytest cache in app/modules and the build directory at the root.",
13
+ )
14
+ def clear_cache():
15
+
16
+ if click.confirm(
17
+ "Are you sure you want to clear the pytest cache and the build directory?"
18
+ ):
19
+
20
+ project_root = Path(os.getenv("WORKING_DIR", ""))
21
+
22
+ pytest_cache_dir = os.path.join(
23
+ PathUtils.get_modules_dir(), ".pytest_cache"
24
+ )
25
+
26
+ build_dir = os.path.join(os.getenv("WORKING_DIR", ""), "build")
27
+
28
+ if os.path.exists(pytest_cache_dir):
29
+ try:
30
+ shutil.rmtree(pytest_cache_dir)
31
+ click.echo(click.style("Pytest cache cleared.", fg="green"))
32
+ except Exception as e:
33
+ click.echo(
34
+ click.style(f"Failed to clear pytest cache: {e}", fg="red")
35
+ )
36
+ else:
37
+ click.echo(
38
+ click.style(
39
+ "No pytest cache found. Nothing to clear.", fg="yellow"
40
+ )
41
+ )
42
+
43
+ if os.path.exists(build_dir):
44
+ try:
45
+ shutil.rmtree(build_dir)
46
+ click.echo(click.style("Build directory cleared.", fg="green"))
47
+ except Exception as e:
48
+ click.echo(
49
+ click.style(
50
+ f"Failed to clear build directory: {e}", fg="red"
51
+ )
52
+ )
53
+ else:
54
+ click.echo(
55
+ click.style(
56
+ "No cache or build directory found. Nothing to clear.",
57
+ fg="yellow",
58
+ )
59
+ )
60
+
61
+ pycache_dirs = project_root.rglob("__pycache__")
62
+ for dir in pycache_dirs:
63
+ try:
64
+ shutil.rmtree(dir)
65
+ except Exception as e:
66
+ click.echo(
67
+ click.style(
68
+ f"Failed to clear __pycache__ directory {dir}: {e}",
69
+ fg="red",
70
+ )
71
+ )
72
+ click.echo(
73
+ click.style("All __pycache__ directories cleared.", fg="green")
74
+ )
75
+
76
+ pyc_files = project_root.rglob("*.pyc")
77
+ for file in pyc_files:
78
+ try:
79
+ file.unlink()
80
+ except Exception as e:
81
+ click.echo(
82
+ click.style(
83
+ f"Failed to clear .pyc file {file}: {e}", fg="red"
84
+ )
85
+ )
86
+
87
+ click.echo(click.style("All cache cleared.", fg="green"))
88
+
89
+ else:
90
+ click.echo(click.style("Clear operation cancelled.", fg="yellow"))
@@ -0,0 +1,31 @@
1
+ import click
2
+ import os
3
+
4
+ from splent_cli.utils.path_utils import PathUtils
5
+
6
+
7
+ @click.command("clear:log", help="Clears the 'app.log' file.")
8
+ def clear_log():
9
+ log_file_path = PathUtils.get_app_log_dir()
10
+
11
+ # Check if the log file exists
12
+ if os.path.exists(log_file_path):
13
+ try:
14
+ # Deletes the log file
15
+ os.remove(log_file_path)
16
+ click.echo(
17
+ click.style(
18
+ "The 'app.log' file has been successfully cleared.",
19
+ fg="green",
20
+ )
21
+ )
22
+ except Exception as e:
23
+ click.echo(
24
+ click.style(
25
+ f"Error clearing the 'app.log' file: {e}", fg="red"
26
+ )
27
+ )
28
+ else:
29
+ click.echo(
30
+ click.style("The 'app.log' file does not exist.", fg="yellow")
31
+ )
@@ -0,0 +1,44 @@
1
+ import click
2
+ import shutil
3
+ import os
4
+
5
+ from splent_cli.utils.path_utils import PathUtils
6
+
7
+
8
+ @click.command(
9
+ "clear:uploads",
10
+ help="Clears the contents of the 'uploads' directory without removing the folder.",
11
+ )
12
+ def clear_uploads():
13
+ uploads_dir = PathUtils.get_uploads_dir()
14
+
15
+ # Verify if the 'uploads' folder exists
16
+ if os.path.exists(uploads_dir) and os.path.isdir(uploads_dir):
17
+ try:
18
+ # Iterate over the contents of the directory
19
+ for filename in os.listdir(uploads_dir):
20
+ file_path = os.path.join(uploads_dir, filename)
21
+
22
+ # If it's a file, remove it
23
+ if os.path.isfile(file_path) or os.path.islink(file_path):
24
+ os.remove(file_path)
25
+ # If it's a directory, remove it and its contents
26
+ elif os.path.isdir(file_path):
27
+ shutil.rmtree(file_path)
28
+
29
+ click.echo(
30
+ click.style(
31
+ "The contents of the 'uploads' directory have been successfully cleared.",
32
+ fg="green",
33
+ )
34
+ )
35
+ except Exception as e:
36
+ click.echo(
37
+ click.style(
38
+ f"Error clearing the 'uploads' directory: {e}", fg="red"
39
+ )
40
+ )
41
+ else:
42
+ click.echo(
43
+ click.style("The 'uploads' directory does not exist.", fg="yellow")
44
+ )
@@ -0,0 +1,50 @@
1
+ import os
2
+ import click
3
+ from dotenv import dotenv_values
4
+ from flask.cli import with_appcontext
5
+
6
+ from splent_cli.utils.path_utils import PathUtils
7
+
8
+
9
+ @click.command(
10
+ "compose:env",
11
+ help="Combines .env files from blueprints with the root .env, checking for conflicts.",
12
+ )
13
+ @with_appcontext
14
+ def compose_env():
15
+
16
+ modules_dir = PathUtils.get_modules_dir()
17
+ root_env_path = PathUtils.get_env_dir()
18
+
19
+ # Loads the current root .env variables into a dictionary
20
+ root_env_vars = dotenv_values(root_env_path)
21
+
22
+ # Finds and processes all blueprints .env files
23
+ module_env_paths = [
24
+ os.path.join(root, ".env")
25
+ for root, dirs, files in os.walk(modules_dir)
26
+ if ".env" in files
27
+ ]
28
+ for env_path in module_env_paths:
29
+ blueprint_env_vars = dotenv_values(env_path)
30
+ # Add or update the blueprint variables in the root .env dictionary
31
+ for key, value in blueprint_env_vars.items():
32
+ if key in root_env_vars and root_env_vars[key] != value:
33
+ conflict_msg = (
34
+ f"Conflict found for variable '{key}' in {env_path}. "
35
+ "Keeping the original value."
36
+ )
37
+ click.echo(click.style(conflict_msg, fg="yellow"))
38
+ continue
39
+ root_env_vars[key] = value
40
+
41
+ # Write back to the root .env file
42
+ with open(root_env_path, "w") as root_env_file:
43
+ for key, value in root_env_vars.items():
44
+ root_env_file.write(f"{key}={value}\n")
45
+
46
+ click.echo(
47
+ click.style(
48
+ "Successfully merged .env files without conflicts.", fg="green"
49
+ )
50
+ )
@@ -0,0 +1,46 @@
1
+ import click
2
+ import subprocess
3
+ import os
4
+
5
+ from splent_cli.utils.path_utils import PathUtils
6
+
7
+
8
+ @click.command(
9
+ "coverage",
10
+ help="Runs pytest coverage on the blueprints directory or a specific module.",
11
+ )
12
+ @click.argument("module_name", required=False)
13
+ @click.option(
14
+ "--html", is_flag=True, help="Generates an HTML coverage report."
15
+ )
16
+ def coverage(module_name, html):
17
+ modules_dir = PathUtils.get_modules_dir()
18
+ test_path = modules_dir
19
+
20
+ if module_name:
21
+ test_path = os.path.join(modules_dir, module_name)
22
+ if not os.path.exists(test_path):
23
+ click.echo(
24
+ click.style(
25
+ f"Module '{module_name}' does not exist.", fg="red"
26
+ )
27
+ )
28
+ return
29
+ click.echo(f"Running coverage for the '{module_name}' module...")
30
+ else:
31
+ click.echo("Running coverage for all modules...")
32
+
33
+ coverage_cmd = [
34
+ "pytest",
35
+ "--ignore-glob=*selenium*",
36
+ "--cov=" + test_path,
37
+ test_path,
38
+ ]
39
+
40
+ if html:
41
+ coverage_cmd.extend(["--cov-report", "html"])
42
+
43
+ try:
44
+ subprocess.run(coverage_cmd, check=True)
45
+ except subprocess.CalledProcessError as e:
46
+ click.echo(click.style(f"Error running coverage: {e}", fg="red"))
@@ -0,0 +1,27 @@
1
+ import click
2
+ import subprocess
3
+ from dotenv import load_dotenv
4
+ import os
5
+
6
+
7
+ @click.command(
8
+ "db:console", help="Opens a MariaDB console with credentials from .env."
9
+ )
10
+ def db_console():
11
+ load_dotenv()
12
+
13
+ mariadb_hostname = os.getenv("MARIADB_HOSTNAME")
14
+ mariadb_user = os.getenv("MARIADB_USER")
15
+ mariadb_password = os.getenv("MARIADB_PASSWORD")
16
+ mariadb_database = os.getenv("MARIADB_DATABASE")
17
+
18
+ # Build the command to connect to MariaDB
19
+ mariadb_connect_cmd = f"mysql -h{mariadb_hostname} -u{mariadb_user} -p{mariadb_password} {mariadb_database}"
20
+
21
+ # Execute the command
22
+ try:
23
+ subprocess.run(mariadb_connect_cmd, shell=True, check=True)
24
+ except subprocess.CalledProcessError as e:
25
+ click.echo(
26
+ click.style(f"Error opening MariaDB console: {e}", fg="red")
27
+ )