faster-app 0.0.11__py3-none-any.whl → 0.0.12__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.
- faster_app/__init__.py +1 -1
- faster_app/commands/base.py +1 -1
- faster_app/commands/builtins/app.py +6 -15
- faster_app/commands/builtins/db.py +1 -1
- faster_app/commands/builtins/fastapi.py +3 -1
- faster_app/commands/discover.py +13 -0
- faster_app/main.py +1 -10
- {faster_app-0.0.11.dist-info → faster_app-0.0.12.dist-info}/METADATA +1 -1
- {faster_app-0.0.11.dist-info → faster_app-0.0.12.dist-info}/RECORD +13 -13
- {faster_app-0.0.11.dist-info → faster_app-0.0.12.dist-info}/WHEEL +0 -0
- {faster_app-0.0.11.dist-info → faster_app-0.0.12.dist-info}/entry_points.txt +0 -0
- {faster_app-0.0.11.dist-info → faster_app-0.0.12.dist-info}/licenses/LICENSE +0 -0
- {faster_app-0.0.11.dist-info → faster_app-0.0.12.dist-info}/top_level.txt +0 -0
faster_app/__init__.py
CHANGED
faster_app/commands/base.py
CHANGED
@@ -60,7 +60,7 @@ class CommandBase(object):
|
|
60
60
|
return attr
|
61
61
|
|
62
62
|
@classmethod
|
63
|
-
def
|
63
|
+
def _get_command_name(cls, class_name: str = None, suffixes: list = None) -> str:
|
64
64
|
"""
|
65
65
|
自动去除类名中的常见后缀,生成简洁的命令名
|
66
66
|
|
@@ -9,18 +9,14 @@ console = Console()
|
|
9
9
|
class AppCommand(CommandBase):
|
10
10
|
"""App Command"""
|
11
11
|
|
12
|
-
async def
|
13
|
-
"""
|
14
|
-
# 拷贝项目根路径下的 main.py 文件到项目根路径
|
15
|
-
shutil.copy(f"{self.BASE_PATH}/main.py", "main.py")
|
16
|
-
console.print("✅ main.py created successfully")
|
17
|
-
|
12
|
+
async def env(self):
|
13
|
+
"""Create .env file"""
|
18
14
|
# 拷贝项目根路径下的 .env.example 文件到项目根路径
|
19
15
|
shutil.copy(f"{self.BASE_PATH}/.env.example", ".env")
|
20
16
|
console.print("✅ .env created successfully")
|
21
17
|
|
22
18
|
async def demo(self):
|
23
|
-
"""
|
19
|
+
"""create demo app"""
|
24
20
|
# 项目根路径下创建 apps 目录,如果存在则跳过
|
25
21
|
if not os.path.exists("apps"):
|
26
22
|
os.makedirs("apps")
|
@@ -28,11 +24,6 @@ class AppCommand(CommandBase):
|
|
28
24
|
shutil.copytree(f"{self.BASE_PATH}/templates/apps/demo", "apps/demo")
|
29
25
|
|
30
26
|
async def config(self):
|
31
|
-
"""
|
32
|
-
#
|
33
|
-
|
34
|
-
os.makedirs("config")
|
35
|
-
# 拷贝 templates/config/settings.py 到 config 目录
|
36
|
-
shutil.copytree(
|
37
|
-
f"{self.BASE_PATH}/templates/config/settings.py", "config/settings.py"
|
38
|
-
)
|
27
|
+
"""create config"""
|
28
|
+
# 拷贝 templates/config 到 . 目录
|
29
|
+
shutil.copytree(f"{self.BASE_PATH}/templates/config", ".")
|
@@ -69,7 +69,9 @@ class FastAPIAppSingleton:
|
|
69
69
|
app = FastAPIAppSingleton()
|
70
70
|
|
71
71
|
|
72
|
-
class
|
72
|
+
class ServerOperations(CommandBase):
|
73
|
+
"""FastAPI Server Operations"""
|
74
|
+
|
73
75
|
def __init__(self, host: str = None, port: int = None):
|
74
76
|
configs = DefaultSettings()
|
75
77
|
self.host = host or configs.HOST
|
faster_app/commands/discover.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
自动发现 apps 目录下的 commands 模块和内置命令
|
3
3
|
"""
|
4
4
|
|
5
|
+
from typing import Dict
|
5
6
|
from faster_app.commands.base import CommandBase
|
6
7
|
from faster_app.base import DiscoverBase
|
7
8
|
|
@@ -22,3 +23,15 @@ class CommandDiscover(DiscoverBase):
|
|
22
23
|
"skip_files": [],
|
23
24
|
},
|
24
25
|
]
|
26
|
+
|
27
|
+
def collect(self) -> Dict[str, CommandBase]:
|
28
|
+
commands = {}
|
29
|
+
command_instances = self.discover()
|
30
|
+
|
31
|
+
# 将命令实例转换为字典,使用类名作为键
|
32
|
+
for instance in command_instances:
|
33
|
+
# 使用 CommandBase 的 _get_command_name 方法自动去除后缀
|
34
|
+
command_name = instance._get_command_name()
|
35
|
+
commands[command_name] = instance
|
36
|
+
|
37
|
+
return commands
|
faster_app/main.py
CHANGED
@@ -10,16 +10,7 @@ def main():
|
|
10
10
|
"""
|
11
11
|
Faster APP 命令行入口点
|
12
12
|
"""
|
13
|
-
|
14
|
-
|
15
|
-
# 将命令实例转换为字典,使用类名作为键
|
16
|
-
commands = {}
|
17
|
-
for instance in command_instances:
|
18
|
-
# 使用 CommandBase 的 get_command_name 方法自动去除后缀
|
19
|
-
command_name = instance.get_command_name()
|
20
|
-
commands[command_name] = instance
|
21
|
-
|
22
|
-
# 直接传递命令字典给 Fire
|
13
|
+
commands = CommandDiscover().collect()
|
23
14
|
fire.Fire(commands)
|
24
15
|
|
25
16
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
faster_app/.env.example,sha256=XMTXjcdM6hWwQiK9gSkWM9NxkryCCgWAVXvEEZRXCZk,413
|
2
|
-
faster_app/__init__.py,sha256=
|
2
|
+
faster_app/__init__.py,sha256=FyUe9NYdfIrBCAIurJ_V2KjCLZJemJXECPMIxIVwGY0,1426
|
3
3
|
faster_app/base.py,sha256=8350gBg_GkW_ww_lDvIOODFOJ71_yowQ5gd_tMTPrQ8,4035
|
4
4
|
faster_app/db.py,sha256=uG4k_eSy5C2MP7DF-senxI10sLAGrLkgmBRFfH_91kY,994
|
5
|
-
faster_app/main.py,sha256=
|
5
|
+
faster_app/main.py,sha256=WVFz5k1bjfnij87JDvT-rXQyd_ufDh25msikSA6TbLs,276
|
6
6
|
faster_app/commands/__init__.py,sha256=AgjI6NmKpdzNTH93XvXsvh54F7PiRX-MJq6emITw7K4,258
|
7
|
-
faster_app/commands/base.py,sha256=
|
8
|
-
faster_app/commands/discover.py,sha256=
|
7
|
+
faster_app/commands/base.py,sha256=mt0sictBXZdnkwQC9x4_MrOS-Z8msFyC72_mFzQ2Zfs,2545
|
8
|
+
faster_app/commands/discover.py,sha256=o6X83vjq3A0rvKnQ6Y1G68tYd9qcVhoYMlYen9zOiK4,1076
|
9
9
|
faster_app/commands/builtins/__init__.py,sha256=Wi3YfjUhZ45VNh7SoLdtCATjAPbWjSwv0gpmFZGJMHA,27
|
10
|
-
faster_app/commands/builtins/app.py,sha256=
|
11
|
-
faster_app/commands/builtins/db.py,sha256=
|
12
|
-
faster_app/commands/builtins/fastapi.py,sha256=
|
10
|
+
faster_app/commands/builtins/app.py,sha256=FZpiaz9EpsdAVFAhUaHMR6medhyjW3X28HtkJ0XyAZE,939
|
11
|
+
faster_app/commands/builtins/db.py,sha256=jrHOngEQw4Xuwf1uW4rZALfQX3M7SzsVTgzYrIVJaes,4735
|
12
|
+
faster_app/commands/builtins/fastapi.py,sha256=o1rj11dUy5b_yoCGDfGX_zor-JPABKbotnvJpT-De3g,2428
|
13
13
|
faster_app/models/__init__.py,sha256=6Mn6zjxF0JJfhDik4LNaXDNLxGgdgl5ECBbqLvgkpxs,334
|
14
14
|
faster_app/models/base.py,sha256=XdWpXQTQDQWwBae8GVhKxwQIAIRwsHRBJ30gQr6ynCQ,2738
|
15
15
|
faster_app/models/discover.py,sha256=fN9yUlVemoqtnXpA-wmHHG_zSX78y2z649Ix-v1oN7E,1640
|
@@ -28,9 +28,9 @@ faster_app/templates/apps/demo/commands.py,sha256=KECFqPzxn46qpveRARoxyyYk_ZVZ-R
|
|
28
28
|
faster_app/templates/apps/demo/models.py,sha256=RfodpzyDfhwbfxfRg_qMwTVFjV7n8uLfJTFsCaWUNHs,328
|
29
29
|
faster_app/templates/apps/demo/routes.py,sha256=Ye1IsU-xDox33IETZQ4K2LLIWkeby9whzVmQqB9JaFY,270
|
30
30
|
faster_app/templates/config/settings.py,sha256=2Q58pumllN5a09mem3bPy-z65Jy5NTTicN4KjGJ-sY8,182
|
31
|
-
faster_app-0.0.
|
32
|
-
faster_app-0.0.
|
33
|
-
faster_app-0.0.
|
34
|
-
faster_app-0.0.
|
35
|
-
faster_app-0.0.
|
36
|
-
faster_app-0.0.
|
31
|
+
faster_app-0.0.12.dist-info/licenses/LICENSE,sha256=VlZLv92YNpRecXnQ92BsEhMZK0zX453xnBFta4eGPRE,1073
|
32
|
+
faster_app-0.0.12.dist-info/METADATA,sha256=Ye1XpFVFEchIqBanMOG0mob5ZKO8fk2cmdzKD5s1wg4,7383
|
33
|
+
faster_app-0.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
34
|
+
faster_app-0.0.12.dist-info/entry_points.txt,sha256=7PnCc_r0NYS1RU2OKbdod2sJBdUt8-JpmCCQSt0OLPs,52
|
35
|
+
faster_app-0.0.12.dist-info/top_level.txt,sha256=Ah5KB3gcZwXCVsxO8kQtaC0Y7Uy__QFm1p_RJGo5UIU,11
|
36
|
+
faster_app-0.0.12.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|