nb-cli-plugin-docker 0.3.0__tar.gz → 0.4.0__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 (19) hide show
  1. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/PKG-INFO +5 -6
  2. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/README.md +2 -2
  3. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/cli.py +11 -11
  4. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/handler.py +20 -18
  5. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/static/reverse/docker/_main.py +0 -1
  6. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/static/reverse/docker/gunicorn_conf.py +1 -1
  7. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/template/docker/docker-compose.yml.jinja +3 -3
  8. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/template/docker/get_driver_type.py.jinja +2 -2
  9. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/pyproject.toml +44 -6
  10. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/LICENSE +0 -0
  11. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/__init__.py +0 -0
  12. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/exception.py +0 -0
  13. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/plugin.py +0 -0
  14. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/static/common/.dockerignore +0 -0
  15. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/static/reverse/docker/start.sh +0 -0
  16. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/template/docker/_helpers.Dockerfile.jinja +0 -0
  17. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/template/docker/forward.Dockerfile.jinja +0 -0
  18. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/template/docker/reverse.Dockerfile.jinja +0 -0
  19. {nb_cli_plugin_docker-0.3.0 → nb_cli_plugin_docker-0.4.0}/nb_cli_plugin_docker/utils.py +0 -0
@@ -1,24 +1,23 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nb-cli-plugin-docker
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: docker support for nb-cli
5
5
  Home-page: https://github.com/nonebot/cli-plugin-docker
6
6
  License: MIT
7
7
  Keywords: nonebot,cli,docker
8
8
  Author: yanyongyu
9
9
  Author-email: yyy@nonebot.dev
10
- Requires-Python: >=3.8,<4.0
10
+ Requires-Python: >=3.9,<4.0
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Framework :: Robot Framework
13
13
  Classifier: Framework :: Robot Framework :: Library
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Operating System :: OS Independent
16
16
  Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
17
  Classifier: Programming Language :: Python :: 3.9
19
18
  Classifier: Programming Language :: Python :: 3.10
20
19
  Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
22
21
  Requires-Dist: nb-cli (>=1.1.0,<2.0.0)
23
22
  Requires-Dist: noneprompt (>=0.1.7,<0.2.0)
24
23
  Project-URL: Documentation, https://github.com/nonebot/cli-plugin-docker#readme
@@ -40,14 +39,14 @@ _✨ NoneBot2 命令行工具 Docker 插件 ✨_
40
39
 
41
40
  <p align="center">
42
41
  <a href="https://raw.githubusercontent.com/nonebot/nb-cli-plugin-docker/master/LICENSE">
43
- <img src="https://img.shields.io/github/license/nonebot/nb-cli-plugin-docker" alt="license">
42
+ <img src="https://img.shields.io/github/license/nonebot/cli-plugin-docker" alt="license">
44
43
  </a>
45
44
  <a href="https://pypi.python.org/pypi/nb-cli-plugin-docker">
46
45
  <img src="https://img.shields.io/pypi/v/nb-cli-plugin-docker" alt="pypi">
47
46
  </a>
48
47
  <img src="https://img.shields.io/badge/python-3.8+-blue" alt="python">
49
48
  <a href="https://results.pre-commit.ci/latest/github/nonebot/nb-cli-plugin-docker/master">
50
- <img src="https://results.pre-commit.ci/badge/github/nonebot/nb-cli-plugin-docker/master.svg" alt="pre-commit" />
49
+ <img src="https://results.pre-commit.ci/badge/github/nonebot/cli-plugin-docker/master.svg" alt="pre-commit" />
51
50
  </a>
52
51
  <br />
53
52
  <a href="https://jq.qq.com/?_wv=1027&k=5OFifDh">
@@ -13,14 +13,14 @@ _✨ NoneBot2 命令行工具 Docker 插件 ✨_
13
13
 
14
14
  <p align="center">
15
15
  <a href="https://raw.githubusercontent.com/nonebot/nb-cli-plugin-docker/master/LICENSE">
16
- <img src="https://img.shields.io/github/license/nonebot/nb-cli-plugin-docker" alt="license">
16
+ <img src="https://img.shields.io/github/license/nonebot/cli-plugin-docker" alt="license">
17
17
  </a>
18
18
  <a href="https://pypi.python.org/pypi/nb-cli-plugin-docker">
19
19
  <img src="https://img.shields.io/pypi/v/nb-cli-plugin-docker" alt="pypi">
20
20
  </a>
21
21
  <img src="https://img.shields.io/badge/python-3.8+-blue" alt="python">
22
22
  <a href="https://results.pre-commit.ci/latest/github/nonebot/nb-cli-plugin-docker/master">
23
- <img src="https://results.pre-commit.ci/badge/github/nonebot/nb-cli-plugin-docker/master.svg" alt="pre-commit" />
23
+ <img src="https://results.pre-commit.ci/badge/github/nonebot/cli-plugin-docker/master.svg" alt="pre-commit" />
24
24
  </a>
25
25
  <br />
26
26
  <a href="https://jq.qq.com/?_wv=1027&k=5OFifDh">
@@ -1,5 +1,5 @@
1
+ from typing import cast
1
2
  from pathlib import Path
2
- from typing import List, cast
3
3
 
4
4
  import click
5
5
  from nb_cli import _
@@ -33,7 +33,7 @@ async def docker(ctx: click.Context):
33
33
  command = cast(ClickAliasedGroup, ctx.command)
34
34
 
35
35
  # auto discover sub commands and scripts
36
- choices: List[Choice[click.Command]] = []
36
+ choices: list[Choice[click.Command]] = []
37
37
  for sub_cmd_name in await run_sync(command.list_commands)(ctx):
38
38
  if sub_cmd := await run_sync(command.get_command)(ctx, sub_cmd_name):
39
39
  choices.append(
@@ -73,7 +73,7 @@ async def generate(ctx: click.Context, force: bool):
73
73
  python_version = await get_python_version(python_path=python_path)
74
74
  python_version = f"{python_version['major']}.{python_version['minor']}"
75
75
 
76
- is_reverse = await get_driver_type(python_path=python_path, cwd=cwd)
76
+ is_asgi = await get_driver_type(python_path=python_path, cwd=cwd)
77
77
  build_backend = await get_build_backend(
78
78
  config_manager=ConfigManager(working_dir=cwd, python_path=python_path)
79
79
  )
@@ -81,19 +81,19 @@ async def generate(ctx: click.Context, force: bool):
81
81
  try:
82
82
  dockerfile = await generate_dockerfile(
83
83
  python_version=python_version,
84
- is_reverse=is_reverse,
84
+ is_asgi=is_asgi,
85
85
  build_backend=build_backend,
86
86
  )
87
87
  await safe_write_file(cwd / "Dockerfile", dockerfile, force=force)
88
88
 
89
- compose_file = await generate_compose_file(is_reverse=is_reverse)
89
+ compose_file = await generate_compose_file(is_asgi=is_asgi)
90
90
  await safe_write_file(cwd / "docker-compose.yml", compose_file, force=force)
91
91
 
92
92
  await safe_copy_dir(
93
93
  Path(__file__).parent / "static" / "common", cwd, force=force
94
94
  )
95
95
 
96
- if is_reverse:
96
+ if is_asgi:
97
97
  await safe_copy_dir(
98
98
  Path(__file__).parent / "static" / "reverse", cwd, force=force
99
99
  )
@@ -112,7 +112,7 @@ async def generate(ctx: click.Context, force: bool):
112
112
  @click.argument("compose_args", nargs=-1)
113
113
  @click.pass_context
114
114
  @run_async
115
- async def up(ctx: click.Context, force: bool, compose_args: List[str]):
115
+ async def up(ctx: click.Context, force: bool, compose_args: list[str]):
116
116
  """Deploy the bot."""
117
117
  cwd = get_project_root()
118
118
 
@@ -130,7 +130,7 @@ async def up(ctx: click.Context, force: bool, compose_args: List[str]):
130
130
  @docker.command(aliases=["stop"], context_settings={"ignore_unknown_options": True})
131
131
  @click.argument("compose_args", nargs=-1)
132
132
  @run_async
133
- async def down(compose_args: List[str]):
133
+ async def down(compose_args: list[str]):
134
134
  """Undeploy the bot."""
135
135
  proc = await compose_down(compose_args)
136
136
  await proc.wait()
@@ -139,7 +139,7 @@ async def down(compose_args: List[str]):
139
139
  @docker.command(context_settings={"ignore_unknown_options": True})
140
140
  @click.argument("compose_args", nargs=-1)
141
141
  @run_async
142
- async def build(compose_args: List[str]):
142
+ async def build(compose_args: list[str]):
143
143
  """Build the bot image."""
144
144
  proc = await compose_build(compose_args)
145
145
  await proc.wait()
@@ -148,7 +148,7 @@ async def build(compose_args: List[str]):
148
148
  @docker.command(context_settings={"ignore_unknown_options": True})
149
149
  @click.argument("compose_args", nargs=-1)
150
150
  @run_async
151
- async def logs(compose_args: List[str]):
151
+ async def logs(compose_args: list[str]):
152
152
  """View the bot logs."""
153
153
  proc = await compose_logs(compose_args)
154
154
  await proc.wait()
@@ -157,7 +157,7 @@ async def logs(compose_args: List[str]):
157
157
  @docker.command(context_settings={"ignore_unknown_options": True})
158
158
  @click.argument("compose_args", nargs=-1)
159
159
  @run_async
160
- async def ps(compose_args: List[str]):
160
+ async def ps(compose_args: list[str]):
161
161
  """View the bot service status."""
162
162
  proc = await compose_ps(compose_args)
163
163
  await proc.wait()
@@ -2,7 +2,7 @@ import json
2
2
  import asyncio
3
3
  from pathlib import Path
4
4
  from dataclasses import dataclass
5
- from typing import IO, TYPE_CHECKING, Any, List, Tuple, Union, Literal, Optional, cast
5
+ from typing import IO, TYPE_CHECKING, Any, Union, Literal, Optional, cast
6
6
 
7
7
  from nb_cli import cache
8
8
  from jinja2 import Environment, FileSystemLoader
@@ -36,14 +36,13 @@ templates.filters.update(cli_templates.filters)
36
36
 
37
37
  @dataclass
38
38
  class Compose:
39
- command: Tuple[str, ...]
39
+ command: tuple[str, ...]
40
40
  info: str
41
41
 
42
42
 
43
43
  if TYPE_CHECKING:
44
44
 
45
- async def get_compose_command() -> Compose:
46
- ...
45
+ async def get_compose_command() -> Compose: ...
47
46
 
48
47
  else:
49
48
 
@@ -68,7 +67,7 @@ else:
68
67
 
69
68
  @ensure_process_terminated
70
69
  async def call_compose(
71
- compose_args: Optional[List[str]] = None,
70
+ compose_args: Optional[list[str]] = None,
72
71
  cwd: Optional[Path] = None,
73
72
  stdin: Optional[Union[IO[Any], int]] = None,
74
73
  stdout: Optional[Union[IO[Any], int]] = None,
@@ -89,7 +88,7 @@ async def call_compose(
89
88
 
90
89
 
91
90
  async def compose_up(
92
- compose_args: Optional[List[str]] = None,
91
+ compose_args: Optional[list[str]] = None,
93
92
  cwd: Optional[Path] = None,
94
93
  stdin: Optional[Union[IO[Any], int]] = None,
95
94
  stdout: Optional[Union[IO[Any], int]] = None,
@@ -105,7 +104,7 @@ async def compose_up(
105
104
 
106
105
 
107
106
  async def compose_down(
108
- compose_args: Optional[List[str]] = None,
107
+ compose_args: Optional[list[str]] = None,
109
108
  cwd: Optional[Path] = None,
110
109
  stdin: Optional[Union[IO[Any], int]] = None,
111
110
  stdout: Optional[Union[IO[Any], int]] = None,
@@ -121,7 +120,7 @@ async def compose_down(
121
120
 
122
121
 
123
122
  async def compose_build(
124
- compose_args: Optional[List[str]] = None,
123
+ compose_args: Optional[list[str]] = None,
125
124
  cwd: Optional[Path] = None,
126
125
  stdin: Optional[Union[IO[Any], int]] = None,
127
126
  stdout: Optional[Union[IO[Any], int]] = None,
@@ -137,7 +136,7 @@ async def compose_build(
137
136
 
138
137
 
139
138
  async def compose_logs(
140
- compose_args: Optional[List[str]] = None,
139
+ compose_args: Optional[list[str]] = None,
141
140
  cwd: Optional[Path] = None,
142
141
  stdin: Optional[Union[IO[Any], int]] = None,
143
142
  stdout: Optional[Union[IO[Any], int]] = None,
@@ -153,7 +152,7 @@ async def compose_logs(
153
152
 
154
153
 
155
154
  async def compose_ps(
156
- compose_args: Optional[List[str]] = None,
155
+ compose_args: Optional[list[str]] = None,
157
156
  cwd: Optional[Path] = None,
158
157
  stdin: Optional[Union[IO[Any], int]] = None,
159
158
  stdout: Optional[Union[IO[Any], int]] = None,
@@ -170,8 +169,8 @@ async def compose_ps(
170
169
 
171
170
  @requires_nonebot
172
171
  async def get_driver_type(
173
- adapters: Optional[List[SimpleInfo]] = None,
174
- builtin_plugins: Optional[List[str]] = None,
172
+ adapters: Optional[list[SimpleInfo]] = None,
173
+ builtin_plugins: Optional[list[str]] = None,
175
174
  python_path: Optional[str] = None,
176
175
  cwd: Optional[Path] = None,
177
176
  ) -> bool:
@@ -198,9 +197,12 @@ async def get_driver_type(
198
197
  )
199
198
  stdout, stderr = await proc.communicate()
200
199
  if proc.returncode != 0:
201
- raise GetDriverTypeError(stderr)
200
+ raise GetDriverTypeError(stdout, stderr)
202
201
 
203
- return json.loads(stdout.strip())
202
+ try:
203
+ return json.loads(stdout.strip())
204
+ except Exception as e:
205
+ raise GetDriverTypeError(stdout, stderr) from e
204
206
 
205
207
 
206
208
  async def get_build_backend(
@@ -220,11 +222,11 @@ async def get_build_backend(
220
222
 
221
223
 
222
224
  async def generate_dockerfile(
223
- python_version: str, is_reverse: bool, build_backend: Optional[str]
225
+ python_version: str, is_asgi: bool, build_backend: Optional[str]
224
226
  ):
225
227
  t = templates.get_template(
226
228
  "docker/reverse.Dockerfile.jinja"
227
- if is_reverse
229
+ if is_asgi
228
230
  else "docker/forward.Dockerfile.jinja"
229
231
  )
230
232
  return await t.render_async(
@@ -232,6 +234,6 @@ async def generate_dockerfile(
232
234
  )
233
235
 
234
236
 
235
- async def generate_compose_file(is_reverse: bool):
237
+ async def generate_compose_file(is_asgi: bool):
236
238
  t = templates.get_template("docker/docker-compose.yml.jinja")
237
- return await t.render_async(is_reverse=is_reverse)
239
+ return await t.render_async(is_asgi=is_asgi)
@@ -1,4 +1,3 @@
1
- import bot
2
1
  import nonebot
3
2
 
4
3
  app = nonebot.get_asgi()
@@ -79,4 +79,4 @@ log_data = {
79
79
  "host": host,
80
80
  "port": port,
81
81
  }
82
- print(json.dumps(log_data))
82
+ print(json.dumps(log_data)) # noqa: T201
@@ -1,6 +1,6 @@
1
1
  version: "3"
2
2
 
3
- {% if is_reverse %}
3
+ {% if is_asgi %}
4
4
  x-config-host: &config-host ${HOST:-0.0.0.0}
5
5
  x-config-port: &config-port ${PORT:-8080}
6
6
  {% endif %}
@@ -8,7 +8,7 @@ x-config-port: &config-port ${PORT:-8080}
8
8
  services:
9
9
  nonebot:
10
10
  build: .
11
- {% if is_reverse %}
11
+ {% if is_asgi %}
12
12
  ports:
13
13
  - *config-port
14
14
  {% endif %}
@@ -16,7 +16,7 @@ services:
16
16
  - .env.prod
17
17
  environment:
18
18
  ENVIRONMENT: prod
19
- {% if is_reverse %}
19
+ {% if is_asgi %}
20
20
  HOST: *config-host
21
21
  PORT: *config-port
22
22
  {% endif %}
@@ -3,11 +3,11 @@
3
3
  import json
4
4
  import nonebot
5
5
  from nonebot.log import logger
6
- from nonebot.drivers import ReverseDriver
6
+ from nonebot.drivers import ASGIMixin
7
7
 
8
8
  logger.remove()
9
9
 
10
10
  {{ prepare_bot(adapters, builtin_plugins) }}
11
11
 
12
12
  driver = nonebot.get_driver()
13
- print(json.dumps(isinstance(driver, ReverseDriver)))
13
+ print(json.dumps(isinstance(driver, ASGIMixin)))
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nb-cli-plugin-docker"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "docker support for nb-cli"
5
5
  authors = ["yanyongyu <yyy@nonebot.dev>"]
6
6
  license = "MIT"
@@ -15,19 +15,20 @@ classifiers = [
15
15
  "Framework :: Robot Framework :: Library",
16
16
  "License :: OSI Approved :: MIT License",
17
17
  "Operating System :: OS Independent",
18
- "Programming Language :: Python :: 3"
18
+ "Programming Language :: Python :: 3",
19
19
  ]
20
20
 
21
21
  [tool.poetry.dependencies]
22
- python = "^3.8"
22
+ python = "^3.9"
23
23
  nb-cli = "^1.1.0"
24
24
  noneprompt = "^0.1.7"
25
25
 
26
26
  [tool.poetry.group.dev.dependencies]
27
+ ruff = "^0.5.0"
27
28
  isort = "^5.10.1"
28
- black = "^22.3.0"
29
+ black = "^24.0.0"
29
30
  nonemoji = "^0.1.2"
30
- pre-commit = "^2.16.0"
31
+ pre-commit = "^3.0.0"
31
32
 
32
33
  [tool.poetry.plugins.nb]
33
34
  docker = "nb_cli_plugin_docker.plugin:install"
@@ -46,11 +47,48 @@ skip_gitignore = true
46
47
  force_sort_within_sections = true
47
48
  extra_standard_library = ["typing_extensions"]
48
49
 
50
+ [tool.ruff]
51
+ line-length = 88
52
+ target-version = "py39"
53
+
54
+ [tool.ruff.lint]
55
+ select = [
56
+ "F", # Pyflakes
57
+ "W", # pycodestyle warnings
58
+ "E", # pycodestyle errors
59
+ "UP", # pyupgrade
60
+ "ASYNC", # flake8-async
61
+ "C4", # flake8-comprehensions
62
+ "T10", # flake8-debugger
63
+ "T20", # flake8-print
64
+ "PYI", # flake8-pyi
65
+ "PT", # flake8-pytest-style
66
+ "Q", # flake8-quotes
67
+ "RUF", # Ruff-specific rules
68
+ ]
69
+ ignore = [
70
+ "E402", # module-import-not-at-top-of-file
71
+ "UP037", # quoted-annotation
72
+ "RUF001", # ambiguous-unicode-character-string
73
+ "RUF002", # ambiguous-unicode-character-docstring
74
+ "RUF003", # ambiguous-unicode-character-comment
75
+ ]
76
+
77
+ [tool.ruff.lint.flake8-pytest-style]
78
+ fixture-parentheses = false
79
+ mark-parentheses = false
80
+
49
81
  [tool.pyright]
50
- pythonVersion = "3.8"
82
+ pythonVersion = "3.9"
51
83
  pythonPlatform = "All"
84
+ defineConstant = { PYDANTIC_V2 = true }
85
+
52
86
  ignore = ["nb_cli_plugin_docker/static/"]
53
87
 
88
+ typeCheckingMode = "standard"
89
+ reportShadowedImports = false
90
+ disableBytesTypePromotions = true
91
+
54
92
  [build-system]
55
93
  requires = ["poetry_core>=1.0.0"]
56
94
  build-backend = "poetry.core.masonry.api"