Implements jeaddons CLI tool
Adds a CLI tool to copy files or folders from a git repository into the current project based on a registry. The tool provides commands to: - `add`: Copies files/folders based on registry entries. - `list`: Lists available registry entries. Registry entries are defined in `jeAddons/registry.py`. The tool supports overriding the registry's ref and destination.
This commit is contained in:
+35
-7
@@ -1,9 +1,37 @@
|
||||
import json
|
||||
import urllib.request
|
||||
|
||||
REGISTRY_URL = "https://raw.githubusercontent.com/acme/registry/main/registry.json"
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
def load_registry():
|
||||
with urllib.request.urlopen(REGISTRY_URL) as r:
|
||||
return json.load(r)
|
||||
class RegistryEntry(TypedDict, total=False):
|
||||
repo: str
|
||||
path: str
|
||||
ref: str
|
||||
dest: str
|
||||
|
||||
|
||||
# Manage your repositories, files, and folders here.
|
||||
# Key = addon name you pass to `jeaddons add <name>`.
|
||||
REGISTRY: dict[str, RegistryEntry] = {
|
||||
# "button": {
|
||||
# "repo": "https://github.com/your-org/templates.git",
|
||||
# "path": "src/components/Button.tsx",
|
||||
# "ref": "main",
|
||||
# "dest": "src/components",
|
||||
# },
|
||||
# "ui": {
|
||||
# "repo": "https://github.com/your-org/templates.git",
|
||||
# "path": "src/components/ui",
|
||||
# "ref": "v1.2.0",
|
||||
# "dest": "src/components",
|
||||
# },
|
||||
}
|
||||
|
||||
|
||||
def load_registry() -> dict[str, RegistryEntry]:
|
||||
return REGISTRY
|
||||
|
||||
|
||||
def get_registry_entry(name: str) -> RegistryEntry:
|
||||
registry = load_registry()
|
||||
if name not in registry:
|
||||
raise KeyError(name)
|
||||
return registry[name]
|
||||
|
||||
Reference in New Issue
Block a user