You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.3 KiB

5 months ago
1 year ago
  1. import json
  2. import os
  3. import re
  4. import sys
  5. # 读取JSON文件
  6. def read_json_file(file_path):
  7. with open(file_path, 'r', encoding='utf-8') as file:
  8. data = json.load(file)
  9. return data
  10. # 保存为JSON文件
  11. def save_json_file(data, file_path):
  12. with open(file_path, 'w', encoding='utf-8') as file:
  13. json.dump(data, file, indent=4, ensure_ascii=False)
  14. def update_file_version(file_path, new_version, key="当前版本/Current Version: v"):
  15. with open(file_path, 'r', encoding='utf-8') as file:
  16. lines = file.readlines()
  17. with open(file_path, 'w', encoding='utf-8') as file:
  18. for line in lines:
  19. if key in line:
  20. pattern = r'('+key+')\d+\.\d+\.\d+'
  21. line = re.sub(pattern, r'\g<1>'+new_version, line)
  22. file.write(line)
  23. version = "0.6.2"
  24. # py html js
  25. if __name__ == "__main__":
  26. file_path = "../.temp_to_pub/compress.py"
  27. update_file_version(file_path, version, key='easyspider_version = "')
  28. file_path = "./src/taskGrid/logic.js"
  29. update_file_version(file_path, version, key='"version": "')
  30. file_path = "../ExecuteStage/easyspider_executestage.py"
  31. update_file_version(file_path, version, key='"version": "')
  32. # index.html
  33. file_path = "./src/index.html"
  34. update_file_version(file_path, version, key="当前版本/Current Version: <b>v")
  35. # package.json
  36. file_path = "./package.json"
  37. # 读取JSON文件
  38. electron_config = read_json_file(file_path)
  39. print(electron_config["version"])
  40. # 修改数据
  41. electron_config["version"] = version
  42. electron_config["config"]["forge"]["packagerConfig"]["appVersion"] = version
  43. # 保存为JSON文件
  44. save_json_file(electron_config, file_path)
  45. # 插件的package.json
  46. file_path = "../Extension/manifest_v3/package.json"
  47. # 读取JSON文件
  48. electron_config = read_json_file(file_path)
  49. print(electron_config["version"])
  50. # 修改数据
  51. electron_config["version"] = version
  52. # 保存为JSON文件
  53. save_json_file(electron_config, file_path)
  54. file_path = "../Extension/manifest_v3/src/manifest.json"
  55. # 读取JSON文件
  56. electron_config = read_json_file(file_path)
  57. print(electron_config["version"])
  58. # 修改数据
  59. electron_config["version"] = version
  60. # 保存为JSON文件
  61. save_json_file(electron_config, file_path)