aury-boot 0.0.12__py3-none-any.whl → 0.0.13__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.
aury/boot/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.0.12'
32
- __version_tuple__ = version_tuple = (0, 0, 12)
31
+ __version__ = version = '0.0.13'
32
+ __version_tuple__ = version_tuple = (0, 0, 13)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -83,8 +83,15 @@ def _detect_project_info(project_dir: Path) -> dict[str, str]:
83
83
  def _render_template(template_name: str, context: dict[str, str]) -> str:
84
84
  """渲染模板。
85
85
 
86
- 支持根目录模板和 aury_docs/ 子目录模板。
86
+ 支持根目录模板、aury_docs/ 子目录模板,且 .env.example 复用 init.py 的 env_templates 逻辑。
87
87
  """
88
+ # 特殊处理 env.example.tpl(通过 init.py 的 env_templates 目录合并生成)
89
+ if template_name == "env.example.tpl":
90
+ from .init import _read_env_template # 复用初始化脚手架的 env 生成逻辑
91
+
92
+ content = _read_env_template()
93
+ return content.format(**context)
94
+
88
95
  # 先在根目录找
89
96
  template_path = TEMPLATES_DIR / template_name
90
97
  if not template_path.exists():
@@ -173,6 +180,60 @@ def _get_aury_docs_templates() -> list[Path]:
173
180
  return sorted(AURY_DOCS_TPL_DIR.glob("*.md.tpl"))
174
181
 
175
182
 
183
+ def generate_aury_docs(
184
+ *,
185
+ project_dir: Path,
186
+ context: dict[str, str],
187
+ force: bool = False,
188
+ dry_run: bool = False,
189
+ quiet: bool = False,
190
+ ) -> int:
191
+ """核心实现:根据 aury_docs 模板生成开发文档包。
192
+
193
+ 被 `aury docs dev` 和 `aury init` 复用,确保生成逻辑一致。
194
+ 返回成功生成的文档数量。
195
+ """
196
+ if not quiet:
197
+ console.print()
198
+
199
+ # 确保输出目录存在
200
+ aury_docs_dir = project_dir / "aury_docs"
201
+ if not dry_run:
202
+ aury_docs_dir.mkdir(parents=True, exist_ok=True)
203
+
204
+ success_count = 0
205
+ for tpl_path in _get_aury_docs_templates():
206
+ try:
207
+ output_name = tpl_path.stem # 去掉 .tpl 后缀,保留 .md
208
+ output_path = aury_docs_dir / output_name
209
+ content = tpl_path.read_text(encoding="utf-8")
210
+ content = content.format(**context)
211
+ # init 直接写文件,不走 rich 提示
212
+ if quiet:
213
+ if output_path.exists() and not force and not dry_run:
214
+ continue
215
+ if not dry_run:
216
+ output_path.write_text(content, encoding="utf-8")
217
+ success_count += 1
218
+ else:
219
+ if _write_file(output_path, content, force=force, dry_run=dry_run):
220
+ success_count += 1
221
+ except Exception as e:
222
+ if not quiet:
223
+ console.print(f"[red]❌ 生成 {tpl_path.name} 失败: {e}[/red]")
224
+ # 静默模式下(init)忽略单个文档失败
225
+ continue
226
+
227
+ if not quiet:
228
+ console.print()
229
+ if dry_run:
230
+ console.print(f"[dim]🔍 预览模式完成,将生成 {success_count} 个文档到 aury_docs/ 目录[/dim]")
231
+ else:
232
+ console.print(f"[green]✨ 完成!成功生成 {success_count} 个文档到 aury_docs/ 目录[/green]")
233
+
234
+ return success_count
235
+
236
+
176
237
  @app.command(name="dev")
177
238
  def generate_dev_doc(
178
239
  project_dir: Path = typer.Argument(
@@ -198,32 +259,16 @@ def generate_dev_doc(
198
259
  ) -> None:
199
260
  """生成/更新 aury_docs/ 开发文档包。"""
200
261
  context = _detect_project_info(project_dir)
201
-
262
+
202
263
  console.print(f"[cyan]📚 检测到项目: {context['project_name']}[/cyan]")
203
- console.print()
204
-
205
- # 确保输出目录存在
206
- aury_docs_dir = project_dir / "aury_docs"
207
- if not dry_run:
208
- aury_docs_dir.mkdir(parents=True, exist_ok=True)
209
-
210
- success_count = 0
211
- for tpl_path in _get_aury_docs_templates():
212
- try:
213
- output_name = tpl_path.stem # 去掉 .tpl 后缀,保留 .md
214
- output_path = aury_docs_dir / output_name
215
- content = tpl_path.read_text(encoding="utf-8")
216
- content = content.format(**context)
217
- if _write_file(output_path, content, force=force, dry_run=dry_run):
218
- success_count += 1
219
- except Exception as e:
220
- console.print(f"[red]❌ 生成 {tpl_path.name} 失败: {e}[/red]")
221
-
222
- console.print()
223
- if dry_run:
224
- console.print(f"[dim]🔍 预览模式完成,将生成 {success_count} 个文档到 aury_docs/ 目录[/dim]")
225
- else:
226
- console.print(f"[green]✨ 完成!成功生成 {success_count} 个文档到 aury_docs/ 目录[/green]")
264
+
265
+ generate_aury_docs(
266
+ project_dir=project_dir,
267
+ context=context,
268
+ force=force,
269
+ dry_run=dry_run,
270
+ quiet=False,
271
+ )
227
272
 
228
273
 
229
274
  @app.command(name="cli")
@@ -836,25 +836,17 @@ def init(
836
836
  else:
837
837
  console.print(" [dim]ℹ️ migrations/ 目录已存在,跳过[/dim]")
838
838
 
839
- # 5. 生成开发文档 (aury_docs/) - 动态扫描模板目录
839
+ # 5. 生成开发文档 (aury_docs/) - 复用 docs.generate_aury_docs
840
840
  console.print("\n[bold]📚 生成开发文档...[/bold]")
841
- aury_docs_tpl_dir = TEMPLATES_DIR / "aury_docs"
842
- aury_docs_dir = base_path / "aury_docs"
843
- aury_docs_dir.mkdir(parents=True, exist_ok=True)
844
- docs_count = 0
845
- if aury_docs_tpl_dir.exists():
846
- for tpl_path in sorted(aury_docs_tpl_dir.glob("*.md.tpl")):
847
- output_name = tpl_path.stem # 去掉 .tpl 后缀,保留 .md
848
- output_path = aury_docs_dir / output_name
849
- if output_path.exists() and not force:
850
- continue
851
- try:
852
- content = tpl_path.read_text(encoding="utf-8")
853
- content = content.format(**template_vars)
854
- output_path.write_text(content, encoding="utf-8")
855
- docs_count += 1
856
- except Exception:
857
- pass
841
+ from .docs import generate_aury_docs
842
+
843
+ docs_count = generate_aury_docs(
844
+ project_dir=base_path,
845
+ context=template_vars,
846
+ force=force,
847
+ dry_run=False,
848
+ quiet=True,
849
+ )
858
850
  console.print(f" [green]✅ 已生成 {docs_count} 个文档到 aury_docs/[/green]")
859
851
 
860
852
  # 6. 生成 Docker 配置
@@ -52,7 +52,7 @@ class PaymentAdapter(BaseAdapter):
52
52
  async def query_order(self, transaction_id: str) -> dict:
53
53
  """查询支付订单。"""
54
54
  response = await self.http_client.get(
55
- f"https://api.payment.com/orders/{transaction_id}"
55
+ f"https://api.payment.com/orders/{{transaction_id}}"
56
56
  )
57
57
  return response.json()
58
58
 
@@ -98,10 +98,10 @@ settings = AdapterSettings()
98
98
  # 方式 2:代码显式配置
99
99
  settings = AdapterSettings(
100
100
  mode="mock",
101
- method_modes={
101
+ method_modes={{
102
102
  "query_order": "real", # query_order 使用真实调用
103
103
  "create_order": "mock", # create_order 使用 Mock
104
- },
104
+ }},
105
105
  debug=True,
106
106
  )
107
107
 
@@ -146,7 +146,7 @@ class WechatAdapter(HttpAdapter):
146
146
  @send_message.mock
147
147
  async def send_message_mock(self, openid: str, content: str) -> dict:
148
148
  """发送消息(Mock)。"""
149
- return {"errcode": 0, "errmsg": "ok", "mock": True}
149
+ return {{"errcode": 0, "errmsg": "ok", "mock": True}}
150
150
  ```
151
151
 
152
152
  ## 16.5 方法级模式覆盖
@@ -272,7 +272,7 @@ class CompositePaymentAdapter(BaseAdapter):
272
272
  elif channel == "wechat":
273
273
  return await self.wechat.create_order(amount, order_id)
274
274
  else:
275
- raise ValueError(f"不支持的支付渠道: {channel}")
275
+ raise ValueError(f"不支持的支付渠道: {{channel}}")
276
276
 
277
277
  @pay.mock
278
278
  async def pay_mock(self, channel: str, amount: int, order_id: str) -> dict:
@@ -350,7 +350,7 @@ THIRD_PARTY__DEBUG=true
350
350
 
351
351
  # 测试环境 (.env.testing)
352
352
  THIRD_PARTY__GATEWAY_MODE=mock
353
- THIRD_PARTY__METHOD_MODES={"query": "sandbox"}
353
+ THIRD_PARTY__METHOD_MODES={{"query": "sandbox"}}
354
354
 
355
355
  # 生产环境 (.env.production)
356
356
  THIRD_PARTY__GATEWAY_MODE=real
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aury-boot
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: Aury Boot - 基于 FastAPI 生态的企业级 API 开发框架
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: alembic>=1.17.2
@@ -1,5 +1,5 @@
1
1
  aury/boot/__init__.py,sha256=pCno-EInnpIBa1OtxNYF-JWf9j95Cd2h6vmu0xqa_-4,1791
2
- aury/boot/_version.py,sha256=AZGfWDETy7COMkzrSothvXJ8vYrPI7kp7_Tcfcp9hUQ,706
2
+ aury/boot/_version.py,sha256=zL2ebKl28AIxVDJJ-NA0JydSncoMv-eXaYp14mDVF3Y,706
3
3
  aury/boot/application/__init__.py,sha256=0o_XmiwFCeAu06VHggS8I1e7_nSMoRq0Hcm0fYfCywU,3071
4
4
  aury/boot/application/adapter/__init__.py,sha256=e1bcSb1bxUMfofTwiCuHBZJk5-STkMCWPF2EJXHQ7UU,3976
5
5
  aury/boot/application/adapter/base.py,sha256=Ar_66fiHPDEmV-1DKnqXKwc53p3pozG31bgTJTEUriY,15763
@@ -45,9 +45,9 @@ aury/boot/commands/add.py,sha256=JRJir92oFHwIBtIKKEjQ7trUhfb9-kCH84x_7saV2gI,264
45
45
  aury/boot/commands/app.py,sha256=k0zHzR3ckt17laAYk6WwwS-lqzS-N8811XjKC-7lerg,7857
46
46
  aury/boot/commands/config.py,sha256=gPkG_jSWrXidjpyVdzABH7uRhoCgX5yrOcdKabtX5wY,4928
47
47
  aury/boot/commands/docker.py,sha256=7mKorZCPZgxH1XFslzo6W-uzpe61hGXz86JKOhOeBlo,9006
48
- aury/boot/commands/docs.py,sha256=-uCvrKj0_shdeBY08W6zx5vNpsBM3yc_IIOOQzoFbqE,11647
48
+ aury/boot/commands/docs.py,sha256=7VaZyEuezmL28aM9y13ni-y-VYP-eNKff5-qb-9q1RQ,13066
49
49
  aury/boot/commands/generate.py,sha256=WZieSXuofxJOC7NBiVGpBigB9NZ4GMcF2F1ReTNun1I,44420
50
- aury/boot/commands/init.py,sha256=4JsQ6U48ZfH_Vzu83k3439gc77Zcmn9arKHgH_kq7HM,32808
50
+ aury/boot/commands/init.py,sha256=vHg2Zhdoar1ANug9J8pT1tNGdH5S0GO19Rhsy-04mXQ,32262
51
51
  aury/boot/commands/pkg.py,sha256=SyHpeSh0vuGVHNmv97-0ZX7AjuSttfZkOs7T86Pq-NQ,14489
52
52
  aury/boot/commands/scheduler.py,sha256=BCIGQcGryXpsYNF-mncP6v5kNoz6DZ10DMzMKVDiXxA,3516
53
53
  aury/boot/commands/worker.py,sha256=qAcPdoKpMBLYoi45X_y2-nobuYKxscJpooEB_0HhM4o,4163
@@ -84,7 +84,7 @@ aury/boot/commands/templates/project/aury_docs/12-admin.md.tpl,sha256=6z3mN54qP2
84
84
  aury/boot/commands/templates/project/aury_docs/13-channel.md.tpl,sha256=rdtlog3ajcSsT0fq9a_US3MPcZhTvDo72eT6hetg4aI,3376
85
85
  aury/boot/commands/templates/project/aury_docs/14-mq.md.tpl,sha256=4bxLQBbCi0Fue0VQWOPt6acZ5P00BoLkCoLPQe_8k4U,2396
86
86
  aury/boot/commands/templates/project/aury_docs/15-events.md.tpl,sha256=a4wQRgVPuYUGTGmw_lX1HJH_yFTbD30mBz7Arc4zgfs,3361
87
- aury/boot/commands/templates/project/aury_docs/16-adapter.md.tpl,sha256=mKLbvIJxHNQOIeDLJH_v5EYaZYEu54K4jGSk8kEianA,11444
87
+ aury/boot/commands/templates/project/aury_docs/16-adapter.md.tpl,sha256=ILwUDaaSQ15W1OM4f8qq4zMi1eSimkT1279Hbw8hTYA,11454
88
88
  aury/boot/commands/templates/project/aury_docs/99-cli.md.tpl,sha256=_dXMK8V7HJAsA_6R1SboD8Rv63s7sDPolvQoSQvKXgA,3667
89
89
  aury/boot/commands/templates/project/env_templates/_header.tpl,sha256=Pt0X_I25o1th3CLR228L2-nlcC-lIkN8cPailohBEkU,513
90
90
  aury/boot/commands/templates/project/env_templates/admin.tpl,sha256=wWt3iybOpBHtuw6CkoUJ1bzEL0aNgOzKDEkMKhI2oag,2032
@@ -192,7 +192,7 @@ aury/boot/testing/client.py,sha256=KOg1EemuIVsBG68G5y0DjSxZGcIQVdWQ4ASaHE3o1R0,4
192
192
  aury/boot/testing/factory.py,sha256=8GvwX9qIDu0L65gzJMlrWB0xbmJ-7zPHuwk3eECULcg,5185
193
193
  aury/boot/toolkit/__init__.py,sha256=AcyVb9fDf3CaEmJPNkWC4iGv32qCPyk4BuFKSuNiJRQ,334
194
194
  aury/boot/toolkit/http/__init__.py,sha256=zIPmpIZ9Qbqe25VmEr7jixoY2fkRbLm7NkCB9vKpg6I,11039
195
- aury_boot-0.0.12.dist-info/METADATA,sha256=YB6RyOOKJdDaZbfk-RhHL041oPN8DZ0kZFRxlrR8mys,7981
196
- aury_boot-0.0.12.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
197
- aury_boot-0.0.12.dist-info/entry_points.txt,sha256=f9KXEkDIGc0BGkgBvsNx_HMz9VhDjNxu26q00jUpDwQ,49
198
- aury_boot-0.0.12.dist-info/RECORD,,
195
+ aury_boot-0.0.13.dist-info/METADATA,sha256=s7J-sRJY-1E1Up1-_wM1dwgzgaK-CNo8wamMlxJjlFM,7981
196
+ aury_boot-0.0.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
197
+ aury_boot-0.0.13.dist-info/entry_points.txt,sha256=f9KXEkDIGc0BGkgBvsNx_HMz9VhDjNxu26q00jUpDwQ,49
198
+ aury_boot-0.0.13.dist-info/RECORD,,