FastAPI-fastkit 1.1.4__py3-none-any.whl → 1.1.5__py3-none-any.whl

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.
@@ -1 +1 @@
1
- __version__ = 'v1.1.4'
1
+ __version__ = 'v1.1.5'
@@ -8,10 +8,14 @@ import subprocess
8
8
  import sys
9
9
  from typing import List
10
10
 
11
- from fastapi_fastkit import console
12
11
  from fastapi_fastkit.core.exceptions import BackendExceptions
13
12
  from fastapi_fastkit.utils.logging import debug_log, get_logger
14
- from fastapi_fastkit.utils.main import handle_exception, print_error, print_success
13
+ from fastapi_fastkit.utils.main import (
14
+ console,
15
+ handle_exception,
16
+ print_error,
17
+ print_success,
18
+ )
15
19
 
16
20
  from .base import BasePackageManager
17
21
 
@@ -8,10 +8,14 @@ import subprocess
8
8
  import sys
9
9
  from typing import List
10
10
 
11
- from fastapi_fastkit import console
12
11
  from fastapi_fastkit.core.exceptions import BackendExceptions
13
12
  from fastapi_fastkit.utils.logging import debug_log, get_logger
14
- from fastapi_fastkit.utils.main import handle_exception, print_error, print_success
13
+ from fastapi_fastkit.utils.main import (
14
+ console,
15
+ handle_exception,
16
+ print_error,
17
+ print_success,
18
+ )
15
19
 
16
20
  from .base import BasePackageManager
17
21
 
@@ -6,10 +6,14 @@
6
6
  import subprocess
7
7
  from typing import List
8
8
 
9
- from fastapi_fastkit import console
10
9
  from fastapi_fastkit.core.exceptions import BackendExceptions
11
10
  from fastapi_fastkit.utils.logging import debug_log, get_logger
12
- from fastapi_fastkit.utils.main import handle_exception, print_error, print_success
11
+ from fastapi_fastkit.utils.main import (
12
+ console,
13
+ handle_exception,
14
+ print_error,
15
+ print_success,
16
+ )
13
17
 
14
18
  from .base import BasePackageManager
15
19
 
@@ -7,10 +7,14 @@ import os
7
7
  import subprocess
8
8
  from typing import List
9
9
 
10
- from fastapi_fastkit import console
11
10
  from fastapi_fastkit.core.exceptions import BackendExceptions
12
11
  from fastapi_fastkit.utils.logging import debug_log, get_logger
13
- from fastapi_fastkit.utils.main import handle_exception, print_error, print_success
12
+ from fastapi_fastkit.utils.main import (
13
+ console,
14
+ handle_exception,
15
+ print_error,
16
+ print_success,
17
+ )
14
18
 
15
19
  from .base import BasePackageManager
16
20
 
fastapi_fastkit/cli.py CHANGED
@@ -1,4 +1,3 @@
1
- # TODO : add a feature to automatically fix appropriate fastkit output console size
2
1
  # --------------------------------------------------------------------------
3
2
  # The Module defines main and core CLI operations for FastAPI-fastkit.
4
3
  #
@@ -31,6 +30,7 @@ from fastapi_fastkit.backend.main import (
31
30
  from fastapi_fastkit.core.exceptions import CLIExceptions
32
31
  from fastapi_fastkit.core.settings import FastkitConfig
33
32
  from fastapi_fastkit.utils.logging import get_logger, setup_logging
33
+ from fastapi_fastkit.utils.main import console as utils_console
34
34
  from fastapi_fastkit.utils.main import (
35
35
  create_info_table,
36
36
  is_fastkit_project,
@@ -41,7 +41,9 @@ from fastapi_fastkit.utils.main import (
41
41
  validate_email,
42
42
  )
43
43
 
44
- from . import __version__, console
44
+ console = utils_console
45
+
46
+ from . import __version__
45
47
 
46
48
 
47
49
  @click.group()
@@ -97,6 +99,7 @@ def echo(ctx: Context) -> None:
97
99
  Deploy FastAPI app foundation instantly at your local!
98
100
 
99
101
  ---
102
+
100
103
  - Project Maintainer : [link=mailto:bbbong9@gmail.com]bnbong(JunHyeok Lee)[/link]
101
104
  - Current Version : {__version__}
102
105
  - Github : [link]https://github.com/bnbong/FastAPI-fastkit[/link]
@@ -135,8 +138,7 @@ def list_templates(ctx: Context) -> None:
135
138
  print_warning("No available templates.")
136
139
  return
137
140
 
138
- table = create_info_table("Available Templates")
139
-
141
+ template_data = {}
140
142
  for template in templates:
141
143
  template_path = os.path.join(template_dir, template)
142
144
  readme_path = os.path.join(template_path, "README.md-tpl")
@@ -148,8 +150,9 @@ def list_templates(ctx: Context) -> None:
148
150
  if first_line.startswith("# "):
149
151
  description = first_line[2:]
150
152
 
151
- table.add_row(template, description)
153
+ template_data[template] = description
152
154
 
155
+ table = create_info_table("Available Templates", template_data)
153
156
  console.print(table)
154
157
 
155
158
 
@@ -15,7 +15,6 @@ from rich.panel import Panel
15
15
  from rich.table import Table
16
16
  from rich.text import Text
17
17
 
18
- from fastapi_fastkit import console
19
18
  from fastapi_fastkit.core.settings import settings
20
19
  from fastapi_fastkit.utils.logging import debug_log, get_logger
21
20
 
@@ -25,6 +24,66 @@ logger = get_logger(__name__)
25
24
  REGEX = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b"
26
25
 
27
26
 
27
+ def get_optimal_console_size() -> tuple[int, int]:
28
+ """
29
+ Get optimal console size based on terminal dimensions.
30
+
31
+ Returns:
32
+ tuple: (width, height) - optimal console dimensions
33
+ """
34
+ try:
35
+ # Get terminal size
36
+ terminal_size = os.get_terminal_size()
37
+ width = terminal_size.columns
38
+ height = terminal_size.lines
39
+
40
+ # Set minimum and maximum constraints
41
+ min_width = 80
42
+ max_width = 120
43
+ min_height = 24
44
+
45
+ # Calculate optimal width (80% of terminal width, but within constraints)
46
+ optimal_width = max(min_width, min(max_width, int(width * 0.8)))
47
+ # Calculate optimal height (leave some space for prompt and buffer)
48
+ optimal_height = max(min_height, height - 5)
49
+
50
+ return optimal_width, optimal_height
51
+ except (OSError, ValueError):
52
+ # Fallback to default size if terminal size detection fails
53
+ return 80, 24
54
+
55
+
56
+ def create_adaptive_console() -> Console:
57
+ """
58
+ Create a console instance with adaptive sizing based on terminal dimensions.
59
+
60
+ Returns:
61
+ Console: Rich console instance with optimal sizing
62
+ """
63
+ if "PYTEST_CURRENT_TEST" in os.environ:
64
+ return Console(no_color=True)
65
+
66
+ width, height = get_optimal_console_size()
67
+ return Console(width=width, height=height)
68
+
69
+
70
+ # Initialize console with adaptive sizing
71
+ console = create_adaptive_console()
72
+
73
+
74
+ def _get_adaptive_panel_width(message: str) -> int:
75
+ """
76
+ Calculate optimal panel width based on message length and terminal size.
77
+
78
+ :param message: Message content
79
+ :return: Optimal panel width
80
+ """
81
+ optimal_width, _ = get_optimal_console_size()
82
+ # Use message length + padding, but constrain to reasonable bounds
83
+ min_width = min(len(message) + 10, optimal_width - 4)
84
+ return max(40, min_width) # Minimum 40 chars, leave margin for borders
85
+
86
+
28
87
  def print_error(
29
88
  message: str,
30
89
  title: str = "Error",
@@ -42,7 +101,9 @@ def print_error(
42
101
  error_text = Text()
43
102
  error_text.append("❌ ", style="bold red")
44
103
  error_text.append(message)
45
- console.print(Panel(error_text, border_style="red", title=title))
104
+
105
+ panel_width = _get_adaptive_panel_width(message)
106
+ console.print(Panel(error_text, border_style="red", title=title, width=panel_width))
46
107
 
47
108
  # Log error for debugging purposes (internal logging)
48
109
  debug_log(f"Error: {message}", "error")
@@ -81,7 +142,11 @@ def print_success(
81
142
  success_text = Text()
82
143
  success_text.append("✨ ", style="bold yellow")
83
144
  success_text.append(message, style="bold green")
84
- console.print(Panel(success_text, border_style="green", title=title))
145
+
146
+ panel_width = _get_adaptive_panel_width(message)
147
+ console.print(
148
+ Panel(success_text, border_style="green", title=title, width=panel_width)
149
+ )
85
150
 
86
151
 
87
152
  def print_warning(
@@ -97,7 +162,11 @@ def print_warning(
97
162
  warning_text = Text()
98
163
  warning_text.append("⚠️ ", style="bold yellow")
99
164
  warning_text.append(message)
100
- console.print(Panel(warning_text, border_style="yellow", title=title))
165
+
166
+ panel_width = _get_adaptive_panel_width(message)
167
+ console.print(
168
+ Panel(warning_text, border_style="yellow", title=title, width=panel_width)
169
+ )
101
170
 
102
171
 
103
172
  def print_info(message: str, title: str = "Info", console: Console = console) -> None:
@@ -111,7 +180,9 @@ def print_info(message: str, title: str = "Info", console: Console = console) ->
111
180
  info_text = Text()
112
181
  info_text.append("ℹ ", style="bold blue")
113
182
  info_text.append(message)
114
- console.print(Panel(info_text, border_style="blue", title=title))
183
+
184
+ panel_width = _get_adaptive_panel_width(message)
185
+ console.print(Panel(info_text, border_style="blue", title=title, width=panel_width))
115
186
 
116
187
 
117
188
  def create_info_table(
@@ -121,7 +192,7 @@ def create_info_table(
121
192
  console: Console = console,
122
193
  ) -> Table:
123
194
  """
124
- Create a table for displaying information.
195
+ Create a table for displaying information that never truncates text.
125
196
 
126
197
  :param title: Title for the table
127
198
  :param data: Dictionary of data to populate the table
@@ -129,13 +200,53 @@ def create_info_table(
129
200
  :param console: Rich console instance
130
201
  :return: Configured Rich Table instance
131
202
  """
132
- table = Table(title=title, show_header=show_header, title_style="bold magenta")
133
- table.add_column("Field", style="cyan")
134
- table.add_column("Value", style="green")
203
+ # Calculate exact content lengths if data exists
204
+ if data:
205
+ max_field_length = max(len(str(key)) for key in data.keys())
206
+ max_value_length = max(len(str(value)) for value in data.values())
207
+
208
+ # Set column widths to exactly match the longest content
209
+ # Add small padding to ensure content fits comfortably
210
+ field_width = max_field_length + 2
211
+ value_width = max_value_length + 2
212
+ else:
213
+ # Default widths for empty tables
214
+ field_width = 15
215
+ value_width = 30
216
+
217
+ # Create table that prioritizes full text display over terminal fitting
218
+ table = Table(
219
+ title=title,
220
+ show_header=show_header,
221
+ title_style="bold magenta",
222
+ expand=False, # Never expand to terminal width
223
+ width=None, # Let table size itself based on content
224
+ pad_edge=False, # Reduce padding to save space
225
+ )
226
+
227
+ # Add columns with settings that prevent any truncation
228
+ table.add_column(
229
+ "Field",
230
+ style="cyan",
231
+ no_wrap=False, # Allow wrapping instead of truncating
232
+ width=field_width, # Exact width for content
233
+ min_width=field_width, # Minimum width to prevent shrinking
234
+ max_width=None, # No maximum width limit
235
+ overflow="fold", # Fold text instead of truncating
236
+ )
237
+ table.add_column(
238
+ "Value",
239
+ style="green",
240
+ no_wrap=False, # Allow wrapping instead of truncating
241
+ width=value_width, # Exact width for content
242
+ min_width=value_width, # Minimum width to prevent shrinking
243
+ max_width=None, # No maximum width limit
244
+ overflow="fold", # Fold text instead of truncating
245
+ )
135
246
 
136
247
  if data:
137
248
  for key, value in data.items():
138
- table.add_row(key, value)
249
+ table.add_row(str(key), str(value))
139
250
 
140
251
  return table
141
252
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: FastAPI-fastkit
3
- Version: 1.1.4
3
+ Version: 1.1.5
4
4
  Summary: Fast, easy-to-use starter kit for new users of Python and FastAPI
5
5
  Author-Email: bnbong <bbbong9@gmail.com>
6
6
  License: MIT
@@ -1,8 +1,8 @@
1
- fastapi_fastkit-1.1.4.dist-info/METADATA,sha256=p1kLLrX1-U760PUwKzqMVAdRETjKPbLFRx67Ijd-oDQ,7545
2
- fastapi_fastkit-1.1.4.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- fastapi_fastkit-1.1.4.dist-info/entry_points.txt,sha256=IONmgb7zWPnJWsCOcpF3u1yP6AWnPjrgWIv49mr1DZE,76
4
- fastapi_fastkit-1.1.4.dist-info/licenses/LICENSE,sha256=2a9cYM3Uy8DW-so6zpYaqUafYT1Dznd3OCWCFe5CKNA,1066
5
- fastapi_fastkit/__init__.py,sha256=wjHlr2gOchEcx5b5dHxSuOpNtMHVZi8osuyoEaEGC3M,23
1
+ fastapi_fastkit-1.1.5.dist-info/METADATA,sha256=lf6J7n0RYB1mwllfTT9Wm5loy1ehicRPHx5htDJ8gFs,7545
2
+ fastapi_fastkit-1.1.5.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
+ fastapi_fastkit-1.1.5.dist-info/entry_points.txt,sha256=IONmgb7zWPnJWsCOcpF3u1yP6AWnPjrgWIv49mr1DZE,76
4
+ fastapi_fastkit-1.1.5.dist-info/licenses/LICENSE,sha256=2a9cYM3Uy8DW-so6zpYaqUafYT1Dznd3OCWCFe5CKNA,1066
5
+ fastapi_fastkit/__init__.py,sha256=yAeZM0H8YsUTXRKj1NAIs8aizaz5iHiUP4JxGs-GGtA,23
6
6
  fastapi_fastkit/__main__.py,sha256=-FS9yUe4IEgDbJjFC1xso-pFCxRzUJ447j6bYpsBTBM,271
7
7
  fastapi_fastkit/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  fastapi_fastkit/backend/inspector.py,sha256=DKaAAp3jE7mfu7aN18rGiGeYSTZ4mtYRMNks5B53CJU,45213
@@ -10,12 +10,12 @@ fastapi_fastkit/backend/main.py,sha256=AqEJgRWqpKvUjP4ul3VxzpyWGRCBttQNgU_Qb2lu6
10
10
  fastapi_fastkit/backend/package_managers/__init__.py,sha256=awSaY-pInI9K4mk1aWqdyKk143AGrcPI4NCy5l_48vw,691
11
11
  fastapi_fastkit/backend/package_managers/base.py,sha256=6IZmIgEgySocVRKH36ffyEMDrnyDYGR3vye7tFjCSRA,4644
12
12
  fastapi_fastkit/backend/package_managers/factory.py,sha256=sfmsAO3WC1IbehQRrAuJx3pDUtfvz3OZEMzd0kkDiZM,5452
13
- fastapi_fastkit/backend/package_managers/pdm_manager.py,sha256=-kCFEY_LPa_TvkZMXG25bLh22mpXTMG6gCcyNXd98nw,9944
14
- fastapi_fastkit/backend/package_managers/pip_manager.py,sha256=TLXUQEDyVvaVccJluYBr7iiRkVOp4PnZYnvjQWthGp4,8067
15
- fastapi_fastkit/backend/package_managers/poetry_manager.py,sha256=VNjrMuotunLHyYmGxJRofH6vesGb5t8ytcklEox9kDg,14248
16
- fastapi_fastkit/backend/package_managers/uv_manager.py,sha256=3V6V-xfQqqsLDNb5l9bnfRhkH6RNJZ339Tk-g8FxKSU,12416
13
+ fastapi_fastkit/backend/package_managers/pdm_manager.py,sha256=5UF2XtSJB5vjTeG4NoziZT8HgMbNfSdJeALGm6sIN6Y,9938
14
+ fastapi_fastkit/backend/package_managers/pip_manager.py,sha256=hNzGIH3WxKUOS9FLcRBe9DANGz4iYaBKUSwZOR8KQm0,8061
15
+ fastapi_fastkit/backend/package_managers/poetry_manager.py,sha256=1wdf090w-n5JhSNlR66drI3JXSqUtO3FuzAEqlKihVw,14242
16
+ fastapi_fastkit/backend/package_managers/uv_manager.py,sha256=F9oXnKgjd-fgLmB6-H9lWZVnMcf_psXyQNCQ3O45BCc,12410
17
17
  fastapi_fastkit/backend/transducer.py,sha256=rIqwJCm5nsruw3qYZYSEoevqOXoKs38MLAmexAM3O7Y,7171
18
- fastapi_fastkit/cli.py,sha256=9qjjNmmJx0Qig4x0bM90HH5_jtgkZg6ZGIzbs6gyQKE,22934
18
+ fastapi_fastkit/cli.py,sha256=52YqTpzZLhJKXMnsfZ4wPiKMWykBeEmulZS9ovNsvJ8,22969
19
19
  fastapi_fastkit/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  fastapi_fastkit/core/exceptions.py,sha256=W29lbDlKE_yKdS-m_QHaWdDB1j3yGge6mVx5mo_jLrU,972
21
21
  fastapi_fastkit/core/settings.py,sha256=_oekl6NllecUoRl5P6RyEgrNNF9Kh_oRxyHziKEeIjY,6085
@@ -244,5 +244,5 @@ fastapi_fastkit/fastapi_project_template/modules/schemas/new_route.py-tpl,sha256
244
244
  fastapi_fastkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
245
245
  fastapi_fastkit/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
246
246
  fastapi_fastkit/utils/logging.py,sha256=oU7BnWInxzl_Gk8kGQ0f6cKdNHZcOVVcSHY4I9MTmR8,6431
247
- fastapi_fastkit/utils/main.py,sha256=hbF9HdJSEKRU0Yn69hMCIMzapyezjxTbKjxVTe98olQ,5593
248
- fastapi_fastkit-1.1.4.dist-info/RECORD,,
247
+ fastapi_fastkit/utils/main.py,sha256=iL1_dM2L2LLfGH9QvKhiup9wiBISrpDkJbXPSn1MJyE,9298
248
+ fastapi_fastkit-1.1.5.dist-info/RECORD,,