dash-devtools 1.0.0__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.
- dash_devtools/__init__.py +8 -0
- dash_devtools/__main__.py +11 -0
- dash_devtools/ai_engine.py +441 -0
- dash_devtools/browser.py +541 -0
- dash_devtools/cli.py +1452 -0
- dash_devtools/database.py +338 -0
- dash_devtools/dbdiagram.py +183 -0
- dash_devtools/e2e.py +329 -0
- dash_devtools/fixers/__init__.py +57 -0
- dash_devtools/fixers/migration_fixer.py +115 -0
- dash_devtools/fixers/ux_fixer.py +106 -0
- dash_devtools/fixers/version_bumper.py +115 -0
- dash_devtools/gas_mes_test.py +1241 -0
- dash_devtools/generators/__init__.py +84 -0
- dash_devtools/health.py +476 -0
- dash_devtools/hooks/__init__.py +250 -0
- dash_devtools/hooks/pre_commit.py +161 -0
- dash_devtools/hooks/pre_push.py +275 -0
- dash_devtools/init_test.py +352 -0
- dash_devtools/markdown_report.py +309 -0
- dash_devtools/migrators/__init__.py +21 -0
- dash_devtools/perf.py +321 -0
- dash_devtools/report.py +667 -0
- dash_devtools/reporters/__init__.py +11 -0
- dash_devtools/spec.py +230 -0
- dash_devtools/stats.py +355 -0
- dash_devtools/test_suite.py +690 -0
- dash_devtools/testing.py +416 -0
- dash_devtools/validators/__init__.py +157 -0
- dash_devtools/validators/backend/__init__.py +12 -0
- dash_devtools/validators/backend/nodejs.py +245 -0
- dash_devtools/validators/backend/python.py +439 -0
- dash_devtools/validators/code_quality.py +243 -0
- dash_devtools/validators/common/__init__.py +11 -0
- dash_devtools/validators/common/quality.py +319 -0
- dash_devtools/validators/common/security.py +270 -0
- dash_devtools/validators/common/spec.py +273 -0
- dash_devtools/validators/detector.py +394 -0
- dash_devtools/validators/frontend/__init__.py +14 -0
- dash_devtools/validators/frontend/angular.py +245 -0
- dash_devtools/validators/frontend/gas.py +310 -0
- dash_devtools/validators/frontend/vite.py +539 -0
- dash_devtools/validators/migration.py +292 -0
- dash_devtools/validators/performance.py +167 -0
- dash_devtools/validators/security.py +205 -0
- dash_devtools/vision/__init__.py +368 -0
- dash_devtools/watch.py +266 -0
- dash_devtools/word_report.py +690 -0
- dash_devtools-1.0.0.dist-info/METADATA +834 -0
- dash_devtools-1.0.0.dist-info/RECORD +53 -0
- dash_devtools-1.0.0.dist-info/WHEEL +5 -0
- dash_devtools-1.0.0.dist-info/entry_points.txt +2 -0
- dash_devtools-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""
|
|
2
|
+
版本號自動更新器
|
|
3
|
+
|
|
4
|
+
自動偵測並更新專案版本號
|
|
5
|
+
支援格式:
|
|
6
|
+
- index.html: <div class="version-info">vX.Y.Z</div>
|
|
7
|
+
- package.json: "version": "X.Y.Z"
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
import json
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class VersionBumper:
|
|
16
|
+
"""版本號自動更新器"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, project_path):
|
|
19
|
+
self.project_path = Path(project_path)
|
|
20
|
+
self.fixes = []
|
|
21
|
+
|
|
22
|
+
def bump_patch(self):
|
|
23
|
+
"""更新 patch 版本號 (X.Y.Z -> X.Y.Z+1)"""
|
|
24
|
+
bumped = False
|
|
25
|
+
|
|
26
|
+
# 嘗試更新 index.html
|
|
27
|
+
index_html = self.project_path / 'index.html'
|
|
28
|
+
if index_html.exists():
|
|
29
|
+
if self._bump_html_version(index_html):
|
|
30
|
+
bumped = True
|
|
31
|
+
|
|
32
|
+
# 嘗試更新 package.json
|
|
33
|
+
package_json = self.project_path / 'package.json'
|
|
34
|
+
if package_json.exists():
|
|
35
|
+
if self._bump_package_version(package_json):
|
|
36
|
+
bumped = True
|
|
37
|
+
|
|
38
|
+
return self.fixes
|
|
39
|
+
|
|
40
|
+
def _bump_html_version(self, file_path):
|
|
41
|
+
"""更新 HTML 中的版本號"""
|
|
42
|
+
try:
|
|
43
|
+
content = file_path.read_text(encoding='utf-8')
|
|
44
|
+
|
|
45
|
+
# 匹配 version-info 中的版本號
|
|
46
|
+
pattern = r'(<div[^>]*class="[^"]*version-info[^"]*"[^>]*>)v?(\d+)\.(\d+)\.(\d+)(</div>)'
|
|
47
|
+
match = re.search(pattern, content)
|
|
48
|
+
|
|
49
|
+
if match:
|
|
50
|
+
prefix = match.group(1)
|
|
51
|
+
major = int(match.group(2))
|
|
52
|
+
minor = int(match.group(3))
|
|
53
|
+
patch = int(match.group(4))
|
|
54
|
+
suffix = match.group(5)
|
|
55
|
+
|
|
56
|
+
new_patch = patch + 1
|
|
57
|
+
old_version = f'{major}.{minor}.{patch}'
|
|
58
|
+
new_version = f'{major}.{minor}.{new_patch}'
|
|
59
|
+
|
|
60
|
+
new_content = content.replace(
|
|
61
|
+
match.group(0),
|
|
62
|
+
f'{prefix}v{new_version}{suffix}'
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
file_path.write_text(new_content, encoding='utf-8')
|
|
66
|
+
self.fixes.append(f'index.html: 版本 v{old_version} -> v{new_version}')
|
|
67
|
+
return True
|
|
68
|
+
|
|
69
|
+
except Exception:
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
def _bump_package_version(self, file_path):
|
|
75
|
+
"""更新 package.json 中的版本號"""
|
|
76
|
+
try:
|
|
77
|
+
content = file_path.read_text(encoding='utf-8')
|
|
78
|
+
data = json.loads(content)
|
|
79
|
+
|
|
80
|
+
if 'version' in data:
|
|
81
|
+
old_version = data['version']
|
|
82
|
+
parts = old_version.split('.')
|
|
83
|
+
|
|
84
|
+
if len(parts) >= 3:
|
|
85
|
+
parts[2] = str(int(parts[2]) + 1)
|
|
86
|
+
new_version = '.'.join(parts)
|
|
87
|
+
data['version'] = new_version
|
|
88
|
+
|
|
89
|
+
# 保持格式
|
|
90
|
+
new_content = json.dumps(data, indent=2, ensure_ascii=False) + '\n'
|
|
91
|
+
file_path.write_text(new_content, encoding='utf-8')
|
|
92
|
+
self.fixes.append(f'package.json: 版本 {old_version} -> {new_version}')
|
|
93
|
+
return True
|
|
94
|
+
|
|
95
|
+
except Exception:
|
|
96
|
+
pass
|
|
97
|
+
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def bump_version_if_fixed(project_path, fixes):
|
|
102
|
+
"""如果有修復,自動更新版本號
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
project_path: 專案路徑
|
|
106
|
+
fixes: 修復清單
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
list: 版本更新訊息
|
|
110
|
+
"""
|
|
111
|
+
if not fixes:
|
|
112
|
+
return []
|
|
113
|
+
|
|
114
|
+
bumper = VersionBumper(project_path)
|
|
115
|
+
return bumper.bump_patch()
|