zt-apollo-cli 0.2.1__tar.gz → 0.2.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zt-apollo-cli
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Apollo configuration management CLI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -31,9 +31,8 @@ pip install -e .
31
31
  ### 打包发布
32
32
 
33
33
  ```bash
34
- python -m pip install --upgrade build twine
35
- python -m build
36
- twine upload dist/*
34
+ uv build
35
+ uv public --token <your_token>
37
36
  ```
38
37
 
39
38
  ## 快速开始
@@ -18,9 +18,8 @@ pip install -e .
18
18
  ### 打包发布
19
19
 
20
20
  ```bash
21
- python -m pip install --upgrade build twine
22
- python -m build
23
- twine upload dist/*
21
+ uv build
22
+ uv public --token <your_token>
24
23
  ```
25
24
 
26
25
  ## 快速开始
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "zt-apollo-cli"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Apollo configuration management CLI"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -8,7 +8,6 @@ from .config import config
8
8
 
9
9
 
10
10
  APOLLO_DOMAIN = ".eminxing.com"
11
- LOGIN_URL = "https://dev-apollo-admin.eminxing.com"
12
11
  REQUIRED_COOKIES = ["SESSION"]
13
12
 
14
13
  def save_cookies(cookies: dict):
@@ -31,7 +30,7 @@ def get_auth_headers(cookies: dict) -> dict:
31
30
  "Accept": "application/json, text/plain, */*",
32
31
  "Accept-Language": "zh-CN,zh;q=0.9",
33
32
  "Connection": "keep-alive",
34
- "Referer": "https://dev-apollo-admin.eminxing.com",
33
+ "Referer": f"{config.base_url}/",
35
34
  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
36
35
  "Cookie": session_cookie,
37
36
  "X-Requested-With": "XMLHttpRequest",
@@ -91,7 +90,7 @@ def get_cookies_from_browser(headless: bool = True) -> dict:
91
90
  context = browser.new_context()
92
91
  page = context.new_page()
93
92
 
94
- page.goto(LOGIN_URL)
93
+ page.goto(config.base_url)
95
94
 
96
95
  # 尝试自动登录
97
96
  if not open_login_page(page):
@@ -4,6 +4,7 @@ import json
4
4
  import shutil
5
5
  from .api import ApolloApi
6
6
  from .auth import login
7
+ from .config import config
7
8
 
8
9
  def _normalize_cell(value):
9
10
  if value is None:
@@ -90,11 +91,18 @@ def render_table(headers, rows, max_width=120, no_truncate_headers=None):
90
91
  show_default=True,
91
92
  help="输出格式: human(表格) / json",
92
93
  )
94
+ @click.option(
95
+ "--base-url",
96
+ default=None,
97
+ help=f"Apollo 地址,默认 {config.DEFAULT_BASE_URL}",
98
+ )
93
99
  @click.pass_context
94
- def cli(ctx, output_format):
100
+ def cli(ctx, output_format, base_url):
95
101
  """Apollo 配置管理命令行工具"""
96
102
  ctx.ensure_object(dict)
97
103
  ctx.obj["output_format"] = output_format.lower()
104
+ if base_url:
105
+ config.set_base_url(base_url)
98
106
 
99
107
  @cli.command("login")
100
108
  @click.option(
@@ -12,10 +12,11 @@ class Config:
12
12
  CONFIG_FILE = CONFIG_DIR / "config.yaml"
13
13
 
14
14
  # Apollo API 默认地址
15
- BASE_URL = "https://dev-apollo-admin.eminxing.com"
15
+ DEFAULT_BASE_URL = "https://dev-apollo-admin.eminxing.com"
16
16
 
17
17
  def __init__(self):
18
18
  self._config = self._load_config()
19
+ self._base_url_override = None
19
20
 
20
21
  def _load_config(self) -> dict:
21
22
  """加载配置文件"""
@@ -30,7 +31,13 @@ class Config:
30
31
 
31
32
  @property
32
33
  def base_url(self) -> str:
33
- return self._config.get("base_url", self.BASE_URL).rstrip("/")
34
+ if self._base_url_override:
35
+ return self._base_url_override.rstrip("/")
36
+ return self._config.get("base_url", self.DEFAULT_BASE_URL).rstrip("/")
37
+
38
+ def set_base_url(self, base_url: str):
39
+ """设置运行时 base_url(仅当前进程生效)"""
40
+ self._base_url_override = base_url.rstrip("/")
34
41
 
35
42
 
36
43
  config = Config()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zt-apollo-cli
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Apollo configuration management CLI
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -31,9 +31,8 @@ pip install -e .
31
31
  ### 打包发布
32
32
 
33
33
  ```bash
34
- python -m pip install --upgrade build twine
35
- python -m build
36
- twine upload dist/*
34
+ uv build
35
+ uv public --token <your_token>
37
36
  ```
38
37
 
39
38
  ## 快速开始
File without changes