You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a clean way to take updates into local source will be valuable for those that cannot utilise the provided packages.
I got a quick python script to install, however there are few notable changes that would need to be made. Allowing a configurable location, and replacing global with public or @NamespaceAccessible public
Python is probably a poor choice as it requires additional installs. Bash could be useful
#!/usr/bin/env python3importargparseimportioimportosimportshutilimportsysimporttempfileimportzipfileimportrequestsfromrequests.adaptersimportHTTPAdapterfromurllib3.util.retryimportRetrySOFTWARE= [
{
"soql-lib": {
"githubUrl": "https://github.com/beyond-the-cloud-dev/soql-lib",
"version": "6.7.0"
}
},
{
"dml-lib": {
"githubUrl": "https://github.com/beyond-the-cloud-dev/dml-lib",
"version": "2.0.0"
}
}
]
defdownload_zip_to_memory(url: str) ->io.BytesIO:
print(f"[1/4] Downloading ZIP from: {url}")
retries=Retry(
total=3,
backoff_factor=0.5,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=["GET", "HEAD"],
raise_on_status=False,
)
s=requests.Session()
s.mount("https://", HTTPAdapter(max_retries=retries))
s.headers.update({"User-Agent": "Mozilla/5.0 (compatible; soql-lib-downloader/1.0)"})
resp=s.get(url, timeout=60) # certificate verification ON by defaultresp.raise_for_status()
print(f" Downloaded {len(resp.content):,} bytes.")
returnio.BytesIO(resp.content)
defextract_zip_to_temp(zip_buf: io.BytesIO) ->str:
print("[2/4] Extracting ZIP to temporary directory...")
zip_buf.seek(0)
withzipfile.ZipFile(zip_buf) aszf:
temp_dir=tempfile.mkdtemp(prefix="soql-lib_")
zf.extractall(temp_dir)
print(f" Extracted to: {temp_dir}")
returntemp_dirdeffind_force_app_default(extract_root: str) ->str:
target_parts= ["force-app", "main", "default"]
print("[3/4] Locating 'force-app/main/default' within extracted contents...")
forroot, dirs, filesinos.walk(extract_root):
parts=os.path.normpath(root).split(os.sep)
iflen(parts) >=3andparts[-3:] ==target_parts:
found_path=rootprint(f" Found: {found_path}")
returnfound_pathraiseFileNotFoundError(
"Could not find 'force-app/main/default' in the extracted ZIP. ""Please verify the ZIP structure or supplied URL."
)
defcopy_contents(src_dir: str, dest_dir: str, clean: bool=False):
print("[4/4] Copying contents to destination...")
print(f" Source: {src_dir}")
print(f" Destination: {dest_dir}")
ifcleanandos.path.exists(dest_dir):
print(" --clean specified: removing destination before copy...")
shutil.rmtree(dest_dir)
os.makedirs(dest_dir, exist_ok=True)
entries=os.listdir(src_dir)
ifnotentries:
print(" Warning: source directory is empty.")
fornameinentries:
s=os.path.join(src_dir, name)
d=os.path.join(dest_dir, name)
ifos.path.isdir(s):
shutil.copytree(s, d, dirs_exist_ok=True)
else:
os.makedirs(os.path.dirname(d), exist_ok=True)
shutil.copy2(s, d)
print(" Copy complete.")
defmain():
# process each sourcefor(software_dict) inSOFTWARE:
forkeyinsoftware_dict:
github_url=software_dict[key]["githubUrl"]
version=software_dict[key]["version"]
zip_url=f"{github_url}/archive/refs/tags/v{version}.zip"dest_path=os.path.join("src", "core", key)
print(f"\nProcessing {key} (version {version})...")
install_source(zip_url, dest_path)
# install_source(DEFAULT_URL, DEFAULT_DEST)definstall_source(url: str, dest: str):
parser=argparse.ArgumentParser(
description="Download a GitHub release ZIP, extract it, and copy files/folders from ""'force-app/main/default' to a local destination."
)
parser.add_argument("--url", default=url, help="ZIP URL to download")
parser.add_argument("--dest", default=dest, help="Destination directory (default: src/core/soql-lib)")
parser.add_argument("--clean", action="store_true", help="Remove destination before copying")
args=parser.parse_args()
try:
zip_buf=download_zip_to_memory(args.url)
extract_root=extract_zip_to_temp(zip_buf)
try:
source_default=find_force_app_default(extract_root)
copy_contents(source_default, args.dest, clean=args.clean)
finally:
try:
shutil.rmtree(extract_root)
exceptExceptionase:
print(f" Warning: failed to remove temp directory: {e}", file=sys.stderr)
print("\n✅ Done.")
print(f" Files from 'force-app/main/default' were copied into: {os.path.abspath(args.dest)}")
exceptExceptionase:
print(f"\n❌ Error: {e}", file=sys.stderr)
sys.exit(1)
if__name__=="__main__":
main()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Having a clean way to take updates into local source will be valuable for those that cannot utilise the provided packages.
I got a quick python script to install, however there are few notable changes that would need to be made. Allowing a configurable location, and replacing
globalwithpublicor@NamespaceAccessible publicPython is probably a poor choice as it requires additional installs. Bash could be useful
Beta Was this translation helpful? Give feedback.
All reactions