Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
ymh0000123 committed Nov 14, 2023
1 parent b794622 commit f879a13
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
28 changes: 19 additions & 9 deletions new_version.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# new_version.py
import json

import json;
import time;
# 读取package.json文件
with open('package.json', 'r') as file:
data = json.load(file)

with open("package.json",'r',encoding='utf-8') as f:
jspack = json.load(f)
# 解析version字段
version = data['version']
major, minor, patch = map(int, version.split('.'))

new_version = '1.1.'+str(int(time.time()))[1:11:1]
jspack['version']=new_version
with open("package.json",'w',encoding='utf-8') as f:
json.dump(jspack, f,ensure_ascii=False)
# 递增version
patch += 1
new_version = f'{major}.{minor}.{patch}'

# 更新package.json中的version字段
data['version'] = new_version

# 将修改后的数据写回package.json文件
with open('package.json', 'w') as file:
json.dump(data, file, indent=2)

print(f'版本号已更新为 {new_version}')
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{"name": "genshin-impact-good-words-and-sentences", "version": "1.1.699883035", "description": "", "main": "script_npm.js", "scripts": {"test": "echo \"Error: no test specified\" && exit 1"}, "author": "", "license": "UNLICENSED"}
{
"name": "genshin-good-words",
"version": "1.0.1",
"description": "",
"main": "script_npm.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "UNLICENSED"
}

0 comments on commit f879a13

Please sign in to comment.