From 4c6c0ab1900f1a98809cec4c0e8b0a01389e56f9 Mon Sep 17 00:00:00 2001 From: John Andersen Date: Thu, 28 Nov 2024 21:12:41 -0800 Subject: [PATCH] feat(deps): deno add atproto api Asciinema: https://asciinema.org/a/692702 Signed-off-by: John Andersen --- pyproject.toml | 4 ++-- src/gitatp/__main__.py | 4 ++++ src/gitatp/git_http_backend.py | 27 +++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/gitatp/__main__.py diff --git a/pyproject.toml b/pyproject.toml index d7d40ed..fcb531f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [project] name = "gitatp" -version = "0.1.4" +version = "0.1.5" description = "Git over ATProto" -long_description = "# Git over ATProto" +long_description = "[![asciicast](https://asciinema.org/a/692702.svg)](https://asciinema.org/a/692702)" long_description_content_type = "text/markdown" readme = {file = "README.md", content-type = "text/markdown"} authors = [ diff --git a/src/gitatp/__main__.py b/src/gitatp/__main__.py new file mode 100644 index 0000000..9ae637f --- /dev/null +++ b/src/gitatp/__main__.py @@ -0,0 +1,4 @@ +from .cli import main + +if __name__ == "__main__": + main() diff --git a/src/gitatp/git_http_backend.py b/src/gitatp/git_http_backend.py index 1571c37..41a1423 100644 --- a/src/gitatp/git_http_backend.py +++ b/src/gitatp/git_http_backend.py @@ -34,7 +34,7 @@ # os.environ["HOME"] = str(Path(__file__).parent.resolve()) parser = argparse.ArgumentParser(prog='atproto-git', usage='%(prog)s [options]') -parser.add_argument('--repos-directory', dest="repos_directory", help='directory for local copies of git repos') +parser.add_argument('--repos-directory', required=True, dest="repos_directory", help='directory for local copies of git repos') args = parser.parse_args() config = configparser.ConfigParser() @@ -116,6 +116,29 @@ def update_profile(client, pinned_post): "ATPROTO_PINNED_POST_CID": pinned_post.cid, }, } + update_profile_deno_cache_path = Path( + "~", ".cache", "update_profile_deno_cache_path", + ).expanduser() + update_profile_deno_cache_path.mkdir(parents=True, exist_ok=True) + + update_profile_deno_cache_path.joinpath( + ATPROTO_UPDATE_PROFILE_JS_PATH.name, + ).write_bytes( + ATPROTO_UPDATE_PROFILE_JS_PATH.read_bytes(), + ) + + if not update_profile_deno_cache_path.joinpath("deno.lock").exists(): + cmd = [ + "deno", + "add", + "npm:@atproto/api", + ] + proc_result = subprocess.run( + cmd, + cwd=str(update_profile_deno_cache_path.resolve()), + ) + proc_result.check_returncode() + cmd = [ "deno", "--allow-env", @@ -124,7 +147,7 @@ def update_profile(client, pinned_post): ] proc_result = subprocess.run( cmd, - cwd=str(ATPROTO_UPDATE_PROFILE_JS_PATH.parent.resolve()), + cwd=str(update_profile_deno_cache_path.resolve()), env=env, ) proc_result.check_returncode()