clean code
This commit is contained in:
parent
307d953ddf
commit
3a25778782
2 changed files with 6 additions and 66 deletions
|
|
@ -9,9 +9,8 @@ photo_view:
|
|||
|
||||
introduction_screen:
|
||||
git: https://github.com/Pyozer/introduction_screen.git
|
||||
# dependencies:
|
||||
dependencies:
|
||||
# flutter_keyboard_visibility_temp_fork:
|
||||
|
||||
dots_indicator:
|
||||
git: https://github.com/Pyozer/dots_indicator.git
|
||||
|
||||
|
|
|
|||
65
update.py
65
update.py
|
|
@ -3,11 +3,9 @@ import os
|
|||
import shutil
|
||||
import subprocess
|
||||
|
||||
# 1. Read the config file
|
||||
with open("config.yaml", "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
|
||||
config_lock = {}
|
||||
|
||||
LOCK_FILE_NAME = "config.lock.yaml"
|
||||
|
|
@ -40,13 +38,10 @@ def get_git_head(repo_path='.'):
|
|||
raise RuntimeError(f"git error: {result.stderr.strip()}")
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
|
||||
def integrate_package(folder_name, data):
|
||||
global config_lock
|
||||
|
||||
repo_url = data['git']
|
||||
# Remove trailing slashes from keep list for easier comparison
|
||||
keep_list = ["lib", "test", "LICENSE", "pubspec.yaml"]
|
||||
if "keep" in data:
|
||||
keep_list += [item.rstrip('/') for item in data['keep']]
|
||||
|
|
@ -54,8 +49,6 @@ def integrate_package(folder_name, data):
|
|||
|
||||
print(f"Processing {folder_name}...")
|
||||
|
||||
# Clone the repository
|
||||
# We check if folder exists to avoid git errors, or remove it to start fresh
|
||||
if os.path.exists(folder_name):
|
||||
shutil.rmtree(folder_name)
|
||||
|
||||
|
|
@ -71,76 +64,24 @@ def integrate_package(folder_name, data):
|
|||
config_lock[folder_name] = last_commit_hash
|
||||
|
||||
|
||||
# 3. Clean up files (Remove all except 'keep')
|
||||
for item in os.listdir(folder_name):
|
||||
# We also usually want to remove the hidden .git folder unless explicitly kept
|
||||
if item not in keep_list:
|
||||
item_path = os.path.join(folder_name, item)
|
||||
|
||||
if os.path.isdir(item_path):
|
||||
shutil.rmtree(item_path) # Delete directory
|
||||
shutil.rmtree(item_path)
|
||||
else:
|
||||
os.remove(item_path) # Delete file
|
||||
|
||||
# 4. Find and replace in .dart files
|
||||
|
||||
# replacing = [
|
||||
# ("import '/", f"import 'package:twonly/src/packages/{folder_name}/lib/"),
|
||||
# ("export '/", f"export 'package:twonly/src/packages/{folder_name}/lib/"),
|
||||
# ]
|
||||
|
||||
# for package_name in all_cloned_packages:
|
||||
# replacing.append(
|
||||
# (f"import 'package:{package_name}/", f"import 'package:twonly/src/packages/{package_name}/lib/")
|
||||
# )
|
||||
# replacing.append(
|
||||
# (f"export 'package:{package_name}/", f"export 'package:twonly/src/packages/{package_name}/lib/")
|
||||
# )
|
||||
|
||||
|
||||
# print(f"Updating imports in .dart files...")
|
||||
|
||||
# os.walk allows us to go into subdirectories recursively
|
||||
# for root, dirs, files in os.walk(folder_name):
|
||||
# for file in files:
|
||||
# if file.endswith(".dart"):
|
||||
# file_path = os.path.join(root, file)
|
||||
|
||||
# try:
|
||||
# with open(file_path, "r", encoding="utf-8") as f:
|
||||
# content = f.read()
|
||||
|
||||
# for search_text, replace_text in replacing:
|
||||
|
||||
# content = content.replace(search_text, replace_text)
|
||||
# content = content.replace(search_text.replace("'", '"'), replace_text.replace("'", '"'))
|
||||
|
||||
# if "replace" in data:
|
||||
# replace = data['replace']
|
||||
# for values in replace:
|
||||
# content = content.replace(values[0], values[1])
|
||||
|
||||
# with open(file_path, "w", encoding="utf-8") as f:
|
||||
# f.write(content)
|
||||
|
||||
# except Exception as e:
|
||||
# print(f"Skipped {file_path}: {e}")
|
||||
|
||||
# print(f"Done! Cleaned {folder_name}.")
|
||||
os.remove(item_path)
|
||||
|
||||
pubspec = {
|
||||
"dependency_overrides": {},
|
||||
}
|
||||
|
||||
|
||||
# 2. Iterate through each entry
|
||||
for folder_name, data in config.items():
|
||||
|
||||
pubspec["dependency_overrides"][folder_name] = {}
|
||||
pubspec["dependency_overrides"][folder_name]["path"] = f"./dependencies/{folder_name}"
|
||||
# update = ["libsignal_protocol_dart"]
|
||||
# if folder_name not in update:
|
||||
# continue
|
||||
|
||||
integrate_package(folder_name, data)
|
||||
if "dependencies" in data:
|
||||
for folder_name, data in data["dependencies"].items():
|
||||
|
|
|
|||
Loading…
Reference in a new issue