tdf_tool 2.4.4__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.
- LICENSE +21 -0
- tdf_tool/app.py +15 -0
- tdf_tool/pipeline.py +36 -0
- tdf_tool/pipelines/annotation.py +119 -0
- tdf_tool/pipelines/api_interaction.py +204 -0
- tdf_tool/pipelines/fix_header.py +36 -0
- tdf_tool/pipelines/git.py +33 -0
- tdf_tool/pipelines/module.py +62 -0
- tdf_tool/pipelines/package.py +49 -0
- tdf_tool/pipelines/router.py +588 -0
- tdf_tool/pipelines/translate.py +48 -0
- tdf_tool/pipelines/upgrade.py +8 -0
- tdf_tool/tools/cli/bean/deps_item.py +46 -0
- tdf_tool/tools/cli/module_deps_rewrite.py +279 -0
- tdf_tool/tools/cli/project_cli.py +119 -0
- tdf_tool/tools/cli/utils/yaml_utils.py +50 -0
- tdf_tool/tools/cmd.py +20 -0
- tdf_tool/tools/config/config.py +114 -0
- tdf_tool/tools/config/initial_json_config.py +38 -0
- tdf_tool/tools/config/module_json_config.py +47 -0
- tdf_tool/tools/config/packages_config.py +127 -0
- tdf_tool/tools/dependencies_analysis.py +212 -0
- tdf_tool/tools/env.py +27 -0
- tdf_tool/tools/fix_header/fix_header_entry.py +80 -0
- tdf_tool/tools/fix_header/fix_header_lint.py +46 -0
- tdf_tool/tools/fix_header/fix_header_lint_tool.py +58 -0
- tdf_tool/tools/fix_header/fix_header_replace_tool.py +100 -0
- tdf_tool/tools/flutter_script.py +36 -0
- tdf_tool/tools/gitlab/gitlab_utils.py +142 -0
- tdf_tool/tools/gitlab/python_gitlab_api.py +109 -0
- tdf_tool/tools/module/module_tools.py +30 -0
- tdf_tool/tools/package/seal_off_package_utils.py +274 -0
- tdf_tool/tools/platform_tools.py +39 -0
- tdf_tool/tools/print.py +45 -0
- tdf_tool/tools/regular_tool.py +211 -0
- tdf_tool/tools/shell_dir.py +165 -0
- tdf_tool/tools/translate/file_util.py +66 -0
- tdf_tool/tools/translate/flutter/flutter_translate_lint.py +273 -0
- tdf_tool/tools/translate/flutter/flutter_translate_tools.py +445 -0
- tdf_tool/tools/translate/flutter/tools/flutter_translate_integrate.py +134 -0
- tdf_tool/tools/translate/ios/ios_translate.py +105 -0
- tdf_tool/tools/translate/ios/ios_translate_lint.py +52 -0
- tdf_tool/tools/translate/ios/tools/batch_pod_tools.py +87 -0
- tdf_tool/tools/translate/ios/tools/ios_module.py +362 -0
- tdf_tool/tools/translate/ios/tools/ios_translate_integrate.py +121 -0
- tdf_tool/tools/translate/ios/tools/ios_translate_pattern.py +22 -0
- tdf_tool/tools/translate/ios/tools/ios_translate_tools.py +213 -0
- tdf_tool/tools/translate/ios/tools/location_string_temp.py +71 -0
- tdf_tool/tools/translate/ios/tools/podspec.py +218 -0
- tdf_tool/tools/translate/ios/tools/string_util.py +91 -0
- tdf_tool/tools/translate/tools/translate_tool.py +154 -0
- tdf_tool/tools/translate/translate_lint.py +44 -0
- tdf_tool/tools/vscode/vscode.py +13 -0
- tdf_tool-2.4.4.dist-info/LICENSE +21 -0
- tdf_tool-2.4.4.dist-info/METADATA +398 -0
- tdf_tool-2.4.4.dist-info/RECORD +58 -0
- tdf_tool-2.4.4.dist-info/WHEEL +4 -0
- tdf_tool-2.4.4.dist-info/entry_points.txt +4 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [fullname]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tdf_tool/app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import fire
|
|
2
|
+
|
|
3
|
+
from tdf_tool.pipeline import Pipeline
|
|
4
|
+
from ruamel import yaml
|
|
5
|
+
|
|
6
|
+
from tdf_tool.tools.print import Print
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import io
|
|
10
|
+
import sys
|
|
11
|
+
# 将标准输出流的编码方式设置为 UTF-8(用于兼容windows)
|
|
12
|
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
13
|
+
|
|
14
|
+
def main():
|
|
15
|
+
fire.Fire(Pipeline())
|
tdf_tool/pipeline.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from tdf_tool.pipelines.module import Module
|
|
3
|
+
from tdf_tool.pipelines.translate import Translate
|
|
4
|
+
from tdf_tool.pipelines.annotation import Annotation
|
|
5
|
+
from tdf_tool.pipelines.fix_header import FixHeader
|
|
6
|
+
from tdf_tool.pipelines.package import Package
|
|
7
|
+
|
|
8
|
+
from tdf_tool.pipelines.git import Git
|
|
9
|
+
from tdf_tool.pipelines.upgrade import Upgrade
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Pipeline:
|
|
13
|
+
"""
|
|
14
|
+
二维火 Flutter 脚手架工具,包含项目构建,依赖分析,git等功能。。
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.module = Module()
|
|
19
|
+
self.translate = Translate()
|
|
20
|
+
self.package = Package()
|
|
21
|
+
self.fixHeader = FixHeader()
|
|
22
|
+
|
|
23
|
+
# 注解整合命令
|
|
24
|
+
self.annotation = Annotation()
|
|
25
|
+
|
|
26
|
+
def upgrade(self):
|
|
27
|
+
"""
|
|
28
|
+
tdf_tool upgrade:升级插件到最新版本
|
|
29
|
+
"""
|
|
30
|
+
Upgrade().run()
|
|
31
|
+
|
|
32
|
+
def git(self, *kwargs, **kwargs1):
|
|
33
|
+
"""
|
|
34
|
+
tdf_tool git【git 命令】:批量操作 git 命令, 例如 tdf_tool git push
|
|
35
|
+
"""
|
|
36
|
+
Git(sys.argv[2:]).run()
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from tdf_tool.tools.config.initial_json_config import InitialJsonConfig
|
|
3
|
+
from tdf_tool.tools.config.module_json_config import ModuleItemType, ModuleJsonConfig
|
|
4
|
+
from tdf_tool.tools.config.packages_config import PackageNode, PackagesJsonConfig
|
|
5
|
+
from tdf_tool.tools.print import Print
|
|
6
|
+
from tdf_tool.tools.shell_dir import ShellDir
|
|
7
|
+
|
|
8
|
+
from tdf_tool.pipelines.router import Router
|
|
9
|
+
from tdf_tool.pipelines.api_interaction import ApiAnnotation
|
|
10
|
+
|
|
11
|
+
class Annotation:
|
|
12
|
+
"""
|
|
13
|
+
模块间支持相关命令:tl annotation -h 查看详情
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self):
|
|
17
|
+
Print.title("检测中...")
|
|
18
|
+
self.__buildRunnerName: str = "build_runner" # build_runner库名
|
|
19
|
+
ShellDir.dirInvalidate()
|
|
20
|
+
self.__routerAnnotation: Router = Router()
|
|
21
|
+
self.__apiAnnotation: ApiAnnotation = ApiAnnotation()
|
|
22
|
+
self.__businessModuleList = self.__api_businessModuleList()
|
|
23
|
+
self.__packagesList: list[PackageNode] = PackagesJsonConfig(ShellDir.getShellDir()).packages # 壳依赖的所有库
|
|
24
|
+
|
|
25
|
+
def start(self):
|
|
26
|
+
"""
|
|
27
|
+
tl annotation start:会以交互式进行操作,对指定的模块执行描述文件(包括路由,api交互)生成和自动注册逻辑
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
Print.str("检测到以下模块可生成描述文件:\n")
|
|
31
|
+
for index, item in enumerate(self.__businessModuleList):
|
|
32
|
+
print(f"{index}: {item}")
|
|
33
|
+
print()
|
|
34
|
+
while True:
|
|
35
|
+
module_name = input("请输入需要生成描述文件的模块名或其下标(input ! 退出,all 自动注册):")
|
|
36
|
+
if module_name == "!" or module_name == "!":
|
|
37
|
+
exit(0)
|
|
38
|
+
elif module_name == "all":
|
|
39
|
+
self.__integrate_shell()
|
|
40
|
+
exit(0)
|
|
41
|
+
elif module_name in self.__businessModuleList:
|
|
42
|
+
self.__generateCode(module_name)
|
|
43
|
+
Print.title(module_name + "描述文件生成完成")
|
|
44
|
+
self.__integrate_shell()
|
|
45
|
+
exit(0)
|
|
46
|
+
else:
|
|
47
|
+
try:
|
|
48
|
+
i = int(module_name)
|
|
49
|
+
if (i < len(self.__businessModuleList)):
|
|
50
|
+
_module_anme = self.__businessModuleList[i]
|
|
51
|
+
self.__generateCode(_module_anme)
|
|
52
|
+
Print.title(_module_anme + "描述文件生成完成")
|
|
53
|
+
self.__integrate_shell()
|
|
54
|
+
exit(0)
|
|
55
|
+
else:
|
|
56
|
+
Print.warning("输入有误,请重新输入")
|
|
57
|
+
except ValueError:
|
|
58
|
+
Print.warning("输入有误,请重新输入")
|
|
59
|
+
|
|
60
|
+
# 生成指定模块的描述文件
|
|
61
|
+
def __generateCode(self, targetModule: str):
|
|
62
|
+
Print.title(targetModule + " 模块生成注解描述文件...")
|
|
63
|
+
for item in self.__packagesList:
|
|
64
|
+
if item.packageName == targetModule:
|
|
65
|
+
if item.isRemote == False:
|
|
66
|
+
ShellDir.goInShellDir()
|
|
67
|
+
if self.__judgeHasBuildRunnerPackage(item.packagePath):
|
|
68
|
+
ShellDir.goInShellDir()
|
|
69
|
+
os.chdir(item.packagePath)
|
|
70
|
+
self.__generatorFunc()
|
|
71
|
+
else:
|
|
72
|
+
Print.str(
|
|
73
|
+
"请确保模块{0}已依赖build_runner,可参考其他模块进行依赖配置❌".format(
|
|
74
|
+
targetModule
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
else:
|
|
78
|
+
Print.str(
|
|
79
|
+
"检测到模块{0}当前是远程依赖,无法生成路由描述文件❌".format(targetModule))
|
|
80
|
+
|
|
81
|
+
# 生成代码
|
|
82
|
+
def __generatorFunc(self):
|
|
83
|
+
os.system("flutter packages pub run build_runner clean")
|
|
84
|
+
os.system(
|
|
85
|
+
"flutter packages pub run build_runner build --delete-conflicting-outputs"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# 判断业务组件下是否有依赖必须的build_runner模块
|
|
89
|
+
def __judgeHasBuildRunnerPackage(self, packageLibPath: str) -> bool:
|
|
90
|
+
os.chdir(packageLibPath)
|
|
91
|
+
packageJsonConfig = PackagesJsonConfig(
|
|
92
|
+
os.getcwd(), filter_by_tdf=False)
|
|
93
|
+
|
|
94
|
+
hasBuildRunner = False
|
|
95
|
+
for item in packageJsonConfig.packages:
|
|
96
|
+
if item.packageName == self.__buildRunnerName:
|
|
97
|
+
hasBuildRunner = True
|
|
98
|
+
|
|
99
|
+
return hasBuildRunner
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def __integrate_shell(self):
|
|
103
|
+
self.__routerAnnotation.integrate_shell()
|
|
104
|
+
self.__apiAnnotation.integrate_shell()
|
|
105
|
+
Print.title("整合完成")
|
|
106
|
+
|
|
107
|
+
def __api_businessModuleList(self):
|
|
108
|
+
__module_config = ModuleJsonConfig()
|
|
109
|
+
__list = []
|
|
110
|
+
for item in InitialJsonConfig().moduleNameList:
|
|
111
|
+
cofig_item = __module_config.get_item(item)
|
|
112
|
+
if (
|
|
113
|
+
cofig_item.type == ModuleItemType.Lib
|
|
114
|
+
or cofig_item.type == ModuleItemType.Api
|
|
115
|
+
or cofig_item.type == ModuleItemType.Module
|
|
116
|
+
or cofig_item.type == ModuleItemType.Plugin
|
|
117
|
+
):
|
|
118
|
+
__list.append(item)
|
|
119
|
+
return __list
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
from tdf_tool.tools.config.packages_config import PackageNode, PackagesJsonConfig
|
|
4
|
+
from tdf_tool.tools.platform_tools import PlatformTools
|
|
5
|
+
from tdf_tool.tools.print import Print
|
|
6
|
+
from tdf_tool.tools.shell_dir import ShellDir
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ImplNode:
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self.packageName = ""
|
|
12
|
+
self.packagePath = ""
|
|
13
|
+
self.filePath = ""
|
|
14
|
+
|
|
15
|
+
def print(self):
|
|
16
|
+
Print.yellow("package:" + self.packageName + "/" + self.filePath)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ApiNode:
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self.packageName = ""
|
|
22
|
+
self.packagePath = ""
|
|
23
|
+
self.filePath = ""
|
|
24
|
+
|
|
25
|
+
def print(self):
|
|
26
|
+
Print.yellow("package:" + self.packageName + "/" + self.filePath)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ApiAnnotation:
|
|
30
|
+
"""
|
|
31
|
+
模块间交互支持相关命令:tl api -h 查看详情
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(self):
|
|
35
|
+
self.ff = None
|
|
36
|
+
self.__implSuffix: str = ".tdf_impl.dart" # 交互描述文件后缀
|
|
37
|
+
self.__implNodeList: list[ImplNode] = [] # impl描述文件列表
|
|
38
|
+
self.__apiSuffix: str = ".tdf_api.dart" # 交互api描述文件后缀
|
|
39
|
+
self.__apiNodeList: list[ApiNode] = [] # api描述文件列表
|
|
40
|
+
self.__interactionDir: str = "tdf_api" # 交互文件目录
|
|
41
|
+
self.__annotationName: str = "tdf_module_api_anno" # 注解库名
|
|
42
|
+
self.__packagesList: list[PackageNode] = [] # 壳依赖的所有库
|
|
43
|
+
|
|
44
|
+
ShellDir.dirInvalidate()
|
|
45
|
+
self.fetch_packages_list()
|
|
46
|
+
|
|
47
|
+
# 遍历壳应用.packages下的所有package,将所有tdf开头的模块都添加入packagesList中
|
|
48
|
+
def fetch_packages_list(self):
|
|
49
|
+
ShellDir.goInShellDir()
|
|
50
|
+
# 遍历壳应用的所有package,将所有tdf开头的模块都添加入packagesList中
|
|
51
|
+
self.__packagesList = PackagesJsonConfig(os.getcwd()).packages
|
|
52
|
+
|
|
53
|
+
# 整合
|
|
54
|
+
def integrate_shell(self):
|
|
55
|
+
# 生成交互文件夹
|
|
56
|
+
tdf_api_dir = self.get_interaction_dir()
|
|
57
|
+
auto_register_file = os.path.join(tdf_api_dir, "api_register.dart")
|
|
58
|
+
self.ff = open(auto_register_file, "w+")
|
|
59
|
+
|
|
60
|
+
# 整合所有 tdf_api.dart 文件
|
|
61
|
+
self.__integrate_tdf_api_files()
|
|
62
|
+
|
|
63
|
+
# 整合所有 tdf_impl.dart 文件
|
|
64
|
+
self.__integrate_tdf_impl_files()
|
|
65
|
+
|
|
66
|
+
# 生成注册代码
|
|
67
|
+
self.__generate_register_code()
|
|
68
|
+
|
|
69
|
+
self.ff.close()
|
|
70
|
+
|
|
71
|
+
# 全部生成文件format
|
|
72
|
+
self.__format__()
|
|
73
|
+
|
|
74
|
+
def __generate_register_code(self):
|
|
75
|
+
for _item in self.__implNodeList:
|
|
76
|
+
self.____import_data_creator(self.ff, _item.packageName, _item.filePath, _item.packageName)
|
|
77
|
+
for _item in self.__apiNodeList:
|
|
78
|
+
self.____import_data_creator(self.ff, _item.packageName, _item.filePath, _item.packageName)
|
|
79
|
+
|
|
80
|
+
self.__import_data_creator_without_alias(self.ff, "tdf_module_api_anno", "tdf_module_api_anno.dart")
|
|
81
|
+
|
|
82
|
+
content = """
|
|
83
|
+
|
|
84
|
+
class TDFApiImplAutoRegister {{
|
|
85
|
+
static List<Type> apis = [
|
|
86
|
+
{0}
|
|
87
|
+
];
|
|
88
|
+
// 确保所有被引用的api库的实现类都已注册
|
|
89
|
+
static void _ensureApiImplRegister() {{
|
|
90
|
+
apis.forEach((element) {{
|
|
91
|
+
if (!ApiRegisterCenter.keys.contains(element)) {{
|
|
92
|
+
throw Exception("${{element}}的实现类未未注册!!!请删除库${{element}}的引用或者引入实现类");
|
|
93
|
+
}}
|
|
94
|
+
}});
|
|
95
|
+
}}
|
|
96
|
+
|
|
97
|
+
static void autoRegister() {{
|
|
98
|
+
{1}
|
|
99
|
+
_ensureApiImplRegister();
|
|
100
|
+
}}
|
|
101
|
+
}}
|
|
102
|
+
"""
|
|
103
|
+
self.ff.write(content.format(
|
|
104
|
+
self.api_list_creator(),
|
|
105
|
+
self.__register_list_creator()))
|
|
106
|
+
|
|
107
|
+
def __register_list_creator(self):
|
|
108
|
+
content = ""
|
|
109
|
+
for item in self.__implNodeList:
|
|
110
|
+
content += """
|
|
111
|
+
ApiRegisterCenter.register({0}.AutoRegister.apiType,{1}.AutoRegister.provider);
|
|
112
|
+
""".format(item.packageName, item.packageName)
|
|
113
|
+
return content
|
|
114
|
+
|
|
115
|
+
def api_list_creator(self):
|
|
116
|
+
content = ""
|
|
117
|
+
for item in self.__apiNodeList:
|
|
118
|
+
content += """
|
|
119
|
+
{0}.TDFApiAutoInvalidate.apiType,
|
|
120
|
+
""".format(item.packageName)
|
|
121
|
+
return content
|
|
122
|
+
|
|
123
|
+
def __integrate_tdf_impl_files(self):
|
|
124
|
+
Print.title("整合所有交互impl文件")
|
|
125
|
+
for packageItem in self.__packagesList:
|
|
126
|
+
__file_path = self.__get_target_file(packageItem.packagePath, self.__implSuffix)
|
|
127
|
+
if __file_path is not None:
|
|
128
|
+
_implNode = ImplNode()
|
|
129
|
+
_implNode.packagePath = packageItem.packagePath
|
|
130
|
+
_implNode.packageName = packageItem.packageName
|
|
131
|
+
_implNode.filePath = __file_path
|
|
132
|
+
_implNode.print()
|
|
133
|
+
self.__implNodeList.append(_implNode)
|
|
134
|
+
|
|
135
|
+
def __integrate_tdf_api_files(self):
|
|
136
|
+
Print.title("整合所有交互api文件")
|
|
137
|
+
for packageItem in self.__packagesList:
|
|
138
|
+
__file_path = self.__get_target_file(packageItem.packagePath, self.__apiSuffix)
|
|
139
|
+
if __file_path is not None:
|
|
140
|
+
_apiNode = ApiNode()
|
|
141
|
+
_apiNode.packagePath = packageItem.packagePath
|
|
142
|
+
_apiNode.packageName = packageItem.packageName
|
|
143
|
+
_apiNode.filePath = __file_path
|
|
144
|
+
_apiNode.print()
|
|
145
|
+
self.__apiNodeList.append(_apiNode)
|
|
146
|
+
|
|
147
|
+
# 获取指定目录下的指定后缀文件
|
|
148
|
+
def __get_target_file(self, file_path: str, suffix: str) -> str:
|
|
149
|
+
ShellDir.goInShellDir()
|
|
150
|
+
os.chdir(file_path)
|
|
151
|
+
|
|
152
|
+
count: int = 0
|
|
153
|
+
__target_file: str
|
|
154
|
+
nowaPath = os.popen(PlatformTools.pwd_cmd()).read().split("\n")[0]
|
|
155
|
+
for root, dirs, files in os.walk(nowaPath):
|
|
156
|
+
for file in files:
|
|
157
|
+
src_file = os.path.join(root, file)
|
|
158
|
+
if src_file.endswith(suffix):
|
|
159
|
+
count += 1
|
|
160
|
+
if PlatformTools.is_windows():
|
|
161
|
+
temp = src_file.split("\lib\\")[1]
|
|
162
|
+
__target_file = temp.replace("\\", "/")
|
|
163
|
+
else:
|
|
164
|
+
__target_file = src_file.split("/lib/")[1]
|
|
165
|
+
if count == 1:
|
|
166
|
+
return __target_file
|
|
167
|
+
elif count > 1:
|
|
168
|
+
raise Exception("模块{0}存在多个交互文件,请检查❌".format(file_path))
|
|
169
|
+
return None
|
|
170
|
+
return None
|
|
171
|
+
|
|
172
|
+
def get_interaction_dir(self):
|
|
173
|
+
ShellDir.goInShellDir()
|
|
174
|
+
os.chdir("lib")
|
|
175
|
+
if os.path.exists(self.__interactionDir):
|
|
176
|
+
shutil.rmtree(self.__interactionDir)
|
|
177
|
+
os.mkdir(self.__interactionDir)
|
|
178
|
+
return os.path.join(ShellDir.getShellDir(), "lib", self.__interactionDir)
|
|
179
|
+
|
|
180
|
+
# 对所有self.__interactionDir目录下的文件执行format
|
|
181
|
+
def __format__(self):
|
|
182
|
+
ShellDir.goInShellLibDir()
|
|
183
|
+
__path = os.path.join(ShellDir.getShellDir(), "lib", self.__interactionDir)
|
|
184
|
+
os.system("dart format {0}".format(__path))
|
|
185
|
+
|
|
186
|
+
# 生成import数据
|
|
187
|
+
def ____import_data_creator(
|
|
188
|
+
self, f_write, module_name, file_path, alias
|
|
189
|
+
):
|
|
190
|
+
f_write.write(
|
|
191
|
+
'import "package:{0}/{1}" as {2};\n'.format(
|
|
192
|
+
module_name, file_path, alias
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
# 生成import数据(无重命名)
|
|
197
|
+
def __import_data_creator_without_alias(
|
|
198
|
+
self, f_write, module_name, file_path
|
|
199
|
+
):
|
|
200
|
+
f_write.write(
|
|
201
|
+
'import "package:{0}/{1}";\n'.format(
|
|
202
|
+
module_name, file_path
|
|
203
|
+
)
|
|
204
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from tdf_tool.tools.shell_dir import ProjectType, ShellDir
|
|
2
|
+
from tdf_tool.tools.print import Print
|
|
3
|
+
from tdf_tool.tools.fix_header.fix_header_lint import FixHeaderLint
|
|
4
|
+
from tdf_tool.tools.fix_header.fix_header_entry import FixHeaderEntry, FixHeaderType
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FixHeader:
|
|
8
|
+
"""
|
|
9
|
+
iOS修复头文件相关:tl fixHeader -h 查看详情
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self.lint = FixHeaderLint()
|
|
14
|
+
self.__fix_entry = FixHeaderEntry(FixHeaderType.REPLACE)
|
|
15
|
+
|
|
16
|
+
def start(self):
|
|
17
|
+
"""
|
|
18
|
+
tl fixHeader start,会以交互式进行进行头文件修复
|
|
19
|
+
"""
|
|
20
|
+
ShellDir.dirInvalidate()
|
|
21
|
+
projectType = ShellDir.getProjectType()
|
|
22
|
+
if projectType == ProjectType.FLUTTER:
|
|
23
|
+
Print.error("tl fixHeader 只支持iOS")
|
|
24
|
+
elif projectType == ProjectType.IOS:
|
|
25
|
+
self.__fix_entry.start()
|
|
26
|
+
|
|
27
|
+
def module(self, name: str):
|
|
28
|
+
"""
|
|
29
|
+
tl fixHeader module【模块名】,修复指定模块名
|
|
30
|
+
"""
|
|
31
|
+
ShellDir.dirInvalidate()
|
|
32
|
+
projectType = ShellDir.getProjectType()
|
|
33
|
+
if projectType == ProjectType.FLUTTER:
|
|
34
|
+
Print.error("tl fixHeader 只支持iOS")
|
|
35
|
+
elif projectType == ProjectType.IOS:
|
|
36
|
+
self.__fix_entry.module(name)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from tdf_tool.tools.config.initial_json_config import InitialJsonConfig
|
|
2
|
+
from tdf_tool.tools.cmd import Cmd
|
|
3
|
+
from tdf_tool.tools.print import Print
|
|
4
|
+
from tdf_tool.tools.shell_dir import ProjectType, ShellDir
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Git:
|
|
8
|
+
"""
|
|
9
|
+
tl git【git 命令】:批量操作 git 命令, 例如 tl git push
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, arg: list):
|
|
13
|
+
self.__gitArg = ["git"] + arg
|
|
14
|
+
self.__arg = arg
|
|
15
|
+
|
|
16
|
+
def run(self):
|
|
17
|
+
ShellDir.dirInvalidate()
|
|
18
|
+
self.__batch_run_git()
|
|
19
|
+
|
|
20
|
+
def __batch_run_git(self):
|
|
21
|
+
ShellDir.goInShellDir()
|
|
22
|
+
projectType = ShellDir.getProjectType()
|
|
23
|
+
if projectType == ProjectType.FLUTTER:
|
|
24
|
+
Print.title("开始操作壳:" + " ".join(self.__gitArg))
|
|
25
|
+
Cmd.runAndPrint(self.__gitArg, shell=False)
|
|
26
|
+
|
|
27
|
+
for module in InitialJsonConfig().moduleNameList:
|
|
28
|
+
ShellDir.goInModuleDir(module)
|
|
29
|
+
Print.title("开始操作" + module + "模块:" + " ".join(self.__gitArg))
|
|
30
|
+
Cmd.runAndPrint(self.__gitArg, shell=False)
|
|
31
|
+
elif projectType == ProjectType.IOS:
|
|
32
|
+
ios_arg = ["bundle", "exec", "pod", "bin", "batch"] + self.__arg
|
|
33
|
+
Cmd.runAndPrint(ios_arg, shell=False)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from tdf_tool.tools.cli.project_cli import ProjectCLI
|
|
2
|
+
from tdf_tool.tools.cmd import Cmd
|
|
3
|
+
from tdf_tool.tools.config.config import CLIJsonConfig
|
|
4
|
+
from tdf_tool.tools.shell_dir import ProjectType, ShellDir
|
|
5
|
+
from tdf_tool.tools.vscode.vscode import VsCodeManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Module:
|
|
9
|
+
"""
|
|
10
|
+
模块相关工具: tl module -h 查看详情
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self):
|
|
14
|
+
self.__cli = ProjectCLI()
|
|
15
|
+
self.__vscodeManager = VsCodeManager()
|
|
16
|
+
|
|
17
|
+
def init(self):
|
|
18
|
+
"""
|
|
19
|
+
项目初始化
|
|
20
|
+
"""
|
|
21
|
+
ShellDir.dirInvalidate()
|
|
22
|
+
self.__cli.initial()
|
|
23
|
+
|
|
24
|
+
def deps(self):
|
|
25
|
+
"""
|
|
26
|
+
修改initial_config.json文件后,执行该命令,更新依赖
|
|
27
|
+
"""
|
|
28
|
+
ShellDir.dirInvalidate()
|
|
29
|
+
ShellDir.goInShellDir()
|
|
30
|
+
projectType = ShellDir.getProjectType()
|
|
31
|
+
if projectType == ProjectType.FLUTTER:
|
|
32
|
+
self.__cli.cliDeps()
|
|
33
|
+
elif projectType == ProjectType.IOS:
|
|
34
|
+
ios_arg = ["bundle", "exec", "pod", "bin", "batch", "clone"]
|
|
35
|
+
Cmd.runAndPrint(ios_arg, shell=False)
|
|
36
|
+
|
|
37
|
+
def depsUnSync(self):
|
|
38
|
+
"""
|
|
39
|
+
修改initial_config.json文件后,执行该命令,更新依赖
|
|
40
|
+
"""
|
|
41
|
+
ShellDir.dirInvalidate()
|
|
42
|
+
ShellDir.goInShellDir()
|
|
43
|
+
projectType = ShellDir.getProjectType()
|
|
44
|
+
if projectType == ProjectType.FLUTTER:
|
|
45
|
+
self.__cli.depsUnSync()
|
|
46
|
+
elif projectType == ProjectType.IOS:
|
|
47
|
+
ios_arg = ["bundle", "exec", "pod", "bin", "batch", "clone"]
|
|
48
|
+
Cmd.runAndPrint(ios_arg, shell=False)
|
|
49
|
+
|
|
50
|
+
def open(self):
|
|
51
|
+
"""
|
|
52
|
+
打开vscode,同时将所有模块添加入vscode中
|
|
53
|
+
"""
|
|
54
|
+
ShellDir.dirInvalidate()
|
|
55
|
+
self.__vscodeManager.openFlutterProject()
|
|
56
|
+
|
|
57
|
+
def module_update(self):
|
|
58
|
+
"""
|
|
59
|
+
更新存储项目git信息的json文件
|
|
60
|
+
"""
|
|
61
|
+
ShellDir.dirInvalidate()
|
|
62
|
+
CLIJsonConfig.updateModuleConfig()
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from tdf_tool.tools.dependencies_analysis import DependencyAnalysis
|
|
3
|
+
from tdf_tool.tools.package.seal_off_package_utils import (
|
|
4
|
+
changeVersionAndDependencies,
|
|
5
|
+
createAndPushTag,
|
|
6
|
+
tagInfoObj,
|
|
7
|
+
)
|
|
8
|
+
from tdf_tool.tools.print import Print
|
|
9
|
+
from tdf_tool.tools.shell_dir import ShellDir
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Package:
|
|
13
|
+
"""
|
|
14
|
+
封包工具相关:tl package -h 查看详情
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def map(self):
|
|
18
|
+
"""
|
|
19
|
+
tl package map:以二维数组形式输出模块的依赖顺序,每一item列表代表可同时打tag的模块
|
|
20
|
+
"""
|
|
21
|
+
ShellDir.dirInvalidate()
|
|
22
|
+
json = DependencyAnalysis().generate()
|
|
23
|
+
print(json)
|
|
24
|
+
exit(0)
|
|
25
|
+
|
|
26
|
+
def tagInfo(self):
|
|
27
|
+
"""
|
|
28
|
+
tl package tagInfo:输出一个json,每一节点包含一个模块,
|
|
29
|
+
内部包含:remote:远程最新版本号;
|
|
30
|
+
current:模块内配置的版本号;
|
|
31
|
+
upgrade:对比自增后的版本号;
|
|
32
|
+
sort:模块打tag顺序,sort相同即代表可同时打tag
|
|
33
|
+
"""
|
|
34
|
+
ShellDir.dirInvalidate()
|
|
35
|
+
tagInfoObj()
|
|
36
|
+
|
|
37
|
+
def prepareTagTask(self, jsonData: str):
|
|
38
|
+
"""
|
|
39
|
+
tl package prepareTagTask:修改yaml中的tag号和所有的依赖,该命令可看成是做打tag前的准备工作,把依赖规范化
|
|
40
|
+
"""
|
|
41
|
+
ShellDir.dirInvalidate()
|
|
42
|
+
changeVersionAndDependencies(jsonData)
|
|
43
|
+
|
|
44
|
+
def tag(self, modules: str):
|
|
45
|
+
"""
|
|
46
|
+
tl package tag:批量tag操作,参数通过逗号隔开,不要有空格。如tdf_tool package tag tdf_widgets
|
|
47
|
+
"""
|
|
48
|
+
ShellDir.dirInvalidate()
|
|
49
|
+
createAndPushTag(modules.split(","))
|