選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

92 行
2.4 KiB

  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.3.5"
  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 = "./src/taskGrid/logic_CN.js"
  31. update_file_version(file_path, version, key='"version": "')
  32. file_path = "../ExecuteStage/easyspider_executestage.py"
  33. update_file_version(file_path, version, key='"version": "')
  34. # index.html
  35. file_path = "./src/index.html"
  36. update_file_version(file_path, version, key="当前版本/Current Version: <b>v")
  37. # package.json
  38. file_path = "./package.json"
  39. # 读取JSON文件
  40. electron_config = read_json_file(file_path)
  41. print(electron_config["version"])
  42. # 修改数据
  43. electron_config["version"] = version
  44. electron_config["config"]["forge"]["packagerConfig"]["appVersion"] = version
  45. # 保存为JSON文件
  46. save_json_file(electron_config, file_path)
  47. # 插件的package.json
  48. file_path = "../Extension/manifest_v3/package.json"
  49. # 读取JSON文件
  50. electron_config = read_json_file(file_path)
  51. print(electron_config["version"])
  52. # 修改数据
  53. electron_config["version"] = version
  54. # 保存为JSON文件
  55. save_json_file(electron_config, file_path)
  56. file_path = "../Extension/manifest_v3/src/manifest.json"
  57. # 读取JSON文件
  58. electron_config = read_json_file(file_path)
  59. print(electron_config["version"])
  60. # 修改数据
  61. electron_config["version"] = version
  62. # 保存为JSON文件
  63. save_json_file(electron_config, file_path)