| |
|
|
| import json |
| import os |
| from datetime import datetime |
|
|
| def update_version(): |
| |
| now = datetime.now() |
| version = f"{now.year}.{now.month}.{now.day}" |
| |
| |
| last_updated_path = "../src/last_updated.json" |
| |
| |
| if not os.path.exists(last_updated_path): |
| print(f"Error: {last_updated_path} not found!") |
| return |
| |
| |
| try: |
| with open(last_updated_path, 'r') as f: |
| last_updated_data = json.load(f) |
| except (json.JSONDecodeError, IOError) as e: |
| print(f"Error reading {last_updated_path}: {e}") |
| return |
| |
| |
| last_updated_data["version"] = version |
| |
| |
| try: |
| with open(last_updated_path, 'w') as f: |
| json.dump(last_updated_data, f) |
| print(f"Updated {last_updated_path} with version: {version}") |
| except IOError as e: |
| print(f"Error writing to {last_updated_path}: {e}") |
| return |
| |
| |
| package_path = "../package.json" |
| |
| |
| if not os.path.exists(package_path): |
| print(f"Error: {package_path} not found!") |
| return |
| |
| |
| try: |
| with open(package_path, 'r') as f: |
| package_data = json.load(f) |
| except (json.JSONDecodeError, IOError) as e: |
| print(f"Error reading {package_path}: {e}") |
| return |
| |
| |
| package_data["version"] = version |
| |
| |
| try: |
| with open(package_path, 'w') as f: |
| json.dump(package_data, f, indent=4) |
| print(f"Updated {package_path} with version: {version}") |
| except IOError as e: |
| print(f"Error writing to {package_path}: {e}") |
| return |
| |
| |
| package_lock_path = "../package-lock.json" |
| |
| |
| if not os.path.exists(package_lock_path): |
| print(f"Error: {package_lock_path} not found!") |
| return |
| |
| |
| try: |
| with open(package_lock_path, 'r') as f: |
| package_lock_data = json.load(f) |
| except (json.JSONDecodeError, IOError) as e: |
| print(f"Error reading {package_lock_path}: {e}") |
| return |
| |
| |
| package_lock_data["version"] = version |
| |
| |
| try: |
| with open(package_lock_path, 'w') as f: |
| json.dump(package_lock_data, f, indent=4) |
| print(f"Updated {package_lock_path} with version: {version}") |
| except IOError as e: |
| print(f"Error writing to {package_lock_path}: {e}") |
|
|
| if __name__ == "__main__": |
| update_version() |