orkestr-cli 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/PKG-INFO +44 -9
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/README.md +41 -7
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli/api.py +13 -1
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli/config.py +6 -0
- orkestr_cli-0.4.0/orkestr_cli/gitinfo.py +108 -0
- orkestr_cli-0.4.0/orkestr_cli/localconfig.py +62 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli/main.py +280 -12
- orkestr_cli-0.4.0/orkestr_cli/sandboxes.py +337 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli.egg-info/PKG-INFO +44 -9
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli.egg-info/SOURCES.txt +6 -1
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli.egg-info/requires.txt +1 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli.egg-info/top_level.txt +0 -1
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/pyproject.toml +5 -2
- orkestr_cli-0.4.0/tests/test_gitinfo.py +110 -0
- orkestr_cli-0.4.0/tests/test_sbx.py +35 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli/__init__.py +0 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli/output.py +0 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli.egg-info/dependency_links.txt +0 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/orkestr_cli.egg-info/entry_points.txt +0 -0
- {orkestr_cli-0.2.0 → orkestr_cli-0.4.0}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: orkestr-cli
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: CLI for the Orkestr deployment platform
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: CLI for the Orkestr deployment platform and sandboxes
|
|
5
5
|
Author-email: Orkestr <hello@orkestr.eu>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://orkestr.eu
|
|
@@ -22,6 +22,7 @@ Description-Content-Type: text/markdown
|
|
|
22
22
|
Requires-Dist: click>=8.1
|
|
23
23
|
Requires-Dist: httpx>=0.27
|
|
24
24
|
Requires-Dist: rich>=13.0
|
|
25
|
+
Requires-Dist: orkestr>=0.4.2
|
|
25
26
|
|
|
26
27
|
# orkestr-cli
|
|
27
28
|
|
|
@@ -39,28 +40,35 @@ pip install orkestr-cli
|
|
|
39
40
|
# Authenticate with your API token
|
|
40
41
|
orkestr login
|
|
41
42
|
|
|
42
|
-
#
|
|
43
|
-
orkestr
|
|
43
|
+
# From inside your app's git repo: detect name/repo/branch and create the project
|
|
44
|
+
orkestr init
|
|
44
45
|
|
|
45
|
-
#
|
|
46
|
+
# Build, deploy, and wait for the live URL
|
|
47
|
+
orkestr deploy .
|
|
48
|
+
|
|
49
|
+
# ...or deploy a named project
|
|
46
50
|
orkestr deploy my-api
|
|
47
51
|
|
|
48
|
-
# View logs
|
|
52
|
+
# View logs / check health
|
|
49
53
|
orkestr logs my-api
|
|
50
|
-
|
|
51
|
-
# Check health
|
|
52
54
|
orkestr health my-api
|
|
53
55
|
```
|
|
54
56
|
|
|
57
|
+
`orkestr init` writes a gitignored `.orkestr/config.json` linking the
|
|
58
|
+
directory to the project, so `orkestr deploy .` knows what to ship. It needs
|
|
59
|
+
an orkestr account and the repo's git provider (GitHub, GitLab, Bitbucket, or
|
|
60
|
+
Codeberg) connected to that account.
|
|
61
|
+
|
|
55
62
|
## Commands
|
|
56
63
|
|
|
57
64
|
| Command | Description |
|
|
58
65
|
|---|---|
|
|
59
66
|
| `orkestr login` / `logout` / `whoami` | Auth |
|
|
67
|
+
| `orkestr init` | Link the current directory to a new project (interactive) |
|
|
60
68
|
| `orkestr projects list\|create\|show\|update\|delete\|analyze` | Manage projects |
|
|
61
69
|
| `orkestr projects env-vars\|webhook\|webhook-toggle <project>` | Project env vars + git webhook |
|
|
62
70
|
| `orkestr envs list\|create\|update\|delete\|env-vars` | Manage environments |
|
|
63
|
-
| `orkestr deploy
|
|
71
|
+
| `orkestr deploy [project]` | Build + deploy, stream the pipeline, print the live URL (`.` = linked dir; `--detach` to not wait) |
|
|
64
72
|
| `orkestr deployments list\|show\|logs\|build-log\|rollback` | Deployment history |
|
|
65
73
|
| `orkestr functions list\|show\|create\|update\|deploy\|delete` | Serverless functions |
|
|
66
74
|
| `orkestr functions logs\|invoke\|env-vars\|metrics\|rotate-key` | Function ops |
|
|
@@ -76,6 +84,33 @@ orkestr health my-api
|
|
|
76
84
|
| `orkestr tokens list\|create\|delete` | API tokens |
|
|
77
85
|
| `orkestr groups list\|show\|create\|delete\|add\|remove` | Project groups (workspaces) |
|
|
78
86
|
| `orkestr connections list\|repos\|disconnect` | Git provider OAuth connections |
|
|
87
|
+
| `orkestr sbx create\|list\|info\|exec\|shell\|metrics\|pause\|resume\|kill` | Sandboxes - isolated ephemeral Linux VMs |
|
|
88
|
+
|
|
89
|
+
## Sandboxes (`orkestr sbx`)
|
|
90
|
+
|
|
91
|
+
The same binary drives [orkestr sandboxes](https://orkestr.eu/sandboxes) -
|
|
92
|
+
isolated, ephemeral Linux VMs for running untrusted or agent-generated code.
|
|
93
|
+
Your `orkestr login` token drives them too (a default-scoped token, or one
|
|
94
|
+
that carries `sandboxes:read` / `sandboxes:write`).
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# create a Python sandbox with restricted egress
|
|
98
|
+
orkestr sbx create python-3.12 --network restricted
|
|
99
|
+
|
|
100
|
+
# run a command, stream its output, inherit its exit code (composes in scripts)
|
|
101
|
+
orkestr sbx exec sbx_01H... "python -c 'print(2**10)'"
|
|
102
|
+
|
|
103
|
+
# park it between turns, then pick it back up
|
|
104
|
+
orkestr sbx pause sbx_01H...
|
|
105
|
+
orkestr sbx resume sbx_01H...
|
|
106
|
+
|
|
107
|
+
# live usage, then terminate
|
|
108
|
+
orkestr sbx metrics sbx_01H...
|
|
109
|
+
orkestr sbx kill sbx_01H...
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`orkestr sbx exec` exits with the command's own exit code. Add `--json` to any
|
|
113
|
+
read command (`list`, `info`, `metrics`, `create`) for machine-readable output.
|
|
79
114
|
|
|
80
115
|
All commands support `--json` for raw JSON output.
|
|
81
116
|
|
|
@@ -14,28 +14,35 @@ pip install orkestr-cli
|
|
|
14
14
|
# Authenticate with your API token
|
|
15
15
|
orkestr login
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
orkestr
|
|
17
|
+
# From inside your app's git repo: detect name/repo/branch and create the project
|
|
18
|
+
orkestr init
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# Build, deploy, and wait for the live URL
|
|
21
|
+
orkestr deploy .
|
|
22
|
+
|
|
23
|
+
# ...or deploy a named project
|
|
21
24
|
orkestr deploy my-api
|
|
22
25
|
|
|
23
|
-
# View logs
|
|
26
|
+
# View logs / check health
|
|
24
27
|
orkestr logs my-api
|
|
25
|
-
|
|
26
|
-
# Check health
|
|
27
28
|
orkestr health my-api
|
|
28
29
|
```
|
|
29
30
|
|
|
31
|
+
`orkestr init` writes a gitignored `.orkestr/config.json` linking the
|
|
32
|
+
directory to the project, so `orkestr deploy .` knows what to ship. It needs
|
|
33
|
+
an orkestr account and the repo's git provider (GitHub, GitLab, Bitbucket, or
|
|
34
|
+
Codeberg) connected to that account.
|
|
35
|
+
|
|
30
36
|
## Commands
|
|
31
37
|
|
|
32
38
|
| Command | Description |
|
|
33
39
|
|---|---|
|
|
34
40
|
| `orkestr login` / `logout` / `whoami` | Auth |
|
|
41
|
+
| `orkestr init` | Link the current directory to a new project (interactive) |
|
|
35
42
|
| `orkestr projects list\|create\|show\|update\|delete\|analyze` | Manage projects |
|
|
36
43
|
| `orkestr projects env-vars\|webhook\|webhook-toggle <project>` | Project env vars + git webhook |
|
|
37
44
|
| `orkestr envs list\|create\|update\|delete\|env-vars` | Manage environments |
|
|
38
|
-
| `orkestr deploy
|
|
45
|
+
| `orkestr deploy [project]` | Build + deploy, stream the pipeline, print the live URL (`.` = linked dir; `--detach` to not wait) |
|
|
39
46
|
| `orkestr deployments list\|show\|logs\|build-log\|rollback` | Deployment history |
|
|
40
47
|
| `orkestr functions list\|show\|create\|update\|deploy\|delete` | Serverless functions |
|
|
41
48
|
| `orkestr functions logs\|invoke\|env-vars\|metrics\|rotate-key` | Function ops |
|
|
@@ -51,6 +58,33 @@ orkestr health my-api
|
|
|
51
58
|
| `orkestr tokens list\|create\|delete` | API tokens |
|
|
52
59
|
| `orkestr groups list\|show\|create\|delete\|add\|remove` | Project groups (workspaces) |
|
|
53
60
|
| `orkestr connections list\|repos\|disconnect` | Git provider OAuth connections |
|
|
61
|
+
| `orkestr sbx create\|list\|info\|exec\|shell\|metrics\|pause\|resume\|kill` | Sandboxes - isolated ephemeral Linux VMs |
|
|
62
|
+
|
|
63
|
+
## Sandboxes (`orkestr sbx`)
|
|
64
|
+
|
|
65
|
+
The same binary drives [orkestr sandboxes](https://orkestr.eu/sandboxes) -
|
|
66
|
+
isolated, ephemeral Linux VMs for running untrusted or agent-generated code.
|
|
67
|
+
Your `orkestr login` token drives them too (a default-scoped token, or one
|
|
68
|
+
that carries `sandboxes:read` / `sandboxes:write`).
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# create a Python sandbox with restricted egress
|
|
72
|
+
orkestr sbx create python-3.12 --network restricted
|
|
73
|
+
|
|
74
|
+
# run a command, stream its output, inherit its exit code (composes in scripts)
|
|
75
|
+
orkestr sbx exec sbx_01H... "python -c 'print(2**10)'"
|
|
76
|
+
|
|
77
|
+
# park it between turns, then pick it back up
|
|
78
|
+
orkestr sbx pause sbx_01H...
|
|
79
|
+
orkestr sbx resume sbx_01H...
|
|
80
|
+
|
|
81
|
+
# live usage, then terminate
|
|
82
|
+
orkestr sbx metrics sbx_01H...
|
|
83
|
+
orkestr sbx kill sbx_01H...
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`orkestr sbx exec` exits with the command's own exit code. Add `--json` to any
|
|
87
|
+
read command (`list`, `info`, `metrics`, `create`) for machine-readable output.
|
|
54
88
|
|
|
55
89
|
All commands support `--json` for raw JSON output.
|
|
56
90
|
|
|
@@ -97,7 +97,7 @@ def list_projects(skip: int = 0, limit: int = 20) -> dict:
|
|
|
97
97
|
|
|
98
98
|
def create_project(name: str, repo_url: str, branch: str = "main",
|
|
99
99
|
display_name: str | None = None, description: str | None = None,
|
|
100
|
-
env_vars: dict | None = None) -> dict:
|
|
100
|
+
env_vars: dict | None = None, build_context: str | None = None) -> dict:
|
|
101
101
|
payload = {"name": name, "repo_url": repo_url, "repo_branch": branch}
|
|
102
102
|
if display_name:
|
|
103
103
|
payload["display_name"] = display_name
|
|
@@ -105,9 +105,21 @@ def create_project(name: str, repo_url: str, branch: str = "main",
|
|
|
105
105
|
payload["description"] = description
|
|
106
106
|
if env_vars:
|
|
107
107
|
payload["env_vars"] = env_vars
|
|
108
|
+
if build_context:
|
|
109
|
+
payload["build_context"] = build_context
|
|
108
110
|
return _post("/api/v1/projects", json=payload)
|
|
109
111
|
|
|
110
112
|
|
|
113
|
+
def detect_services(repo_url: str, branch: str = "main") -> dict:
|
|
114
|
+
"""Detect deployable services in a repo (monorepo support).
|
|
115
|
+
|
|
116
|
+
Note: detect-services is served under /api/projects (not the /api/v1
|
|
117
|
+
prefix the rest of these calls use) — confirmed against the live API.
|
|
118
|
+
"""
|
|
119
|
+
return _post("/api/projects/detect-services",
|
|
120
|
+
params={"repo_url": repo_url, "branch": branch})
|
|
121
|
+
|
|
122
|
+
|
|
111
123
|
def get_project(project_id: str) -> dict:
|
|
112
124
|
return _get(f"/api/v1/projects/{project_id}")
|
|
113
125
|
|
|
@@ -36,6 +36,12 @@ def get_api_url() -> str:
|
|
|
36
36
|
return load().get("api_url", DEFAULTS["api_url"])
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
def get_token() -> str | None:
|
|
40
|
+
"""Return the raw bearer token (API token or session access token), or None."""
|
|
41
|
+
cfg = load()
|
|
42
|
+
return cfg.get("api_token") or cfg.get("access_token")
|
|
43
|
+
|
|
44
|
+
|
|
39
45
|
def get_auth_header() -> dict[str, str]:
|
|
40
46
|
"""Return the Authorization header dict, or empty dict if not logged in."""
|
|
41
47
|
cfg = load()
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Read repo metadata straight from a local .git directory.
|
|
2
|
+
|
|
3
|
+
No git binary required — init only needs the origin URL and current branch,
|
|
4
|
+
both of which are plain text in .git/config and .git/HEAD. Parsing them
|
|
5
|
+
ourselves keeps init working in containers and minimal images that ship
|
|
6
|
+
without the git CLI.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def find_git_root(start: Path | None = None) -> Path | None:
|
|
14
|
+
"""Walk up from start (default cwd) to the directory containing .git."""
|
|
15
|
+
path = (start or Path.cwd()).resolve()
|
|
16
|
+
for candidate in [path, *path.parents]:
|
|
17
|
+
if (candidate / ".git").exists():
|
|
18
|
+
return candidate
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def normalize_remote_url(url: str) -> str:
|
|
23
|
+
"""Normalize any git remote URL to an https:// clone URL.
|
|
24
|
+
|
|
25
|
+
Handles the three forms a remote shows up as:
|
|
26
|
+
git@github.com:user/repo.git (scp-like ssh)
|
|
27
|
+
ssh://git@github.com/user/repo.git (ssh url)
|
|
28
|
+
https://github.com/user/repo.git (already https)
|
|
29
|
+
The trailing .git and any embedded credentials are stripped.
|
|
30
|
+
"""
|
|
31
|
+
url = url.strip()
|
|
32
|
+
|
|
33
|
+
# scp-like: [user@]host:path
|
|
34
|
+
m = re.match(r"^(?:ssh://)?(?:[^@/]+@)?([^:/]+):(.+?)(?:\.git)?/?$", url)
|
|
35
|
+
if m and "://" not in url:
|
|
36
|
+
return f"https://{m.group(1)}/{m.group(2)}"
|
|
37
|
+
|
|
38
|
+
# ssh://[user@]host[:port]/path
|
|
39
|
+
m = re.match(r"^ssh://(?:[^@/]+@)?([^/:]+)(?::\d+)?/(.+?)(?:\.git)?/?$", url)
|
|
40
|
+
if m:
|
|
41
|
+
return f"https://{m.group(1)}/{m.group(2)}"
|
|
42
|
+
|
|
43
|
+
# http(s)://[user[:pass]@]host/path — strip creds + trailing .git
|
|
44
|
+
m = re.match(r"^(https?://)(?:[^@/]+@)?(.+?)(?:\.git)?/?$", url)
|
|
45
|
+
if m:
|
|
46
|
+
return f"{m.group(1)}{m.group(2)}"
|
|
47
|
+
|
|
48
|
+
return url
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def read_origin_url(git_root: Path) -> str | None:
|
|
52
|
+
"""Return the normalized origin remote URL, or the first remote found.
|
|
53
|
+
|
|
54
|
+
Parses .git/config by hand rather than via configparser: git indents
|
|
55
|
+
entries with tabs, which configparser misreads as value continuations.
|
|
56
|
+
"""
|
|
57
|
+
cfg = git_root / ".git" / "config"
|
|
58
|
+
if not cfg.exists():
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
remotes: dict[str, str] = {}
|
|
62
|
+
current_remote: str | None = None
|
|
63
|
+
for raw in cfg.read_text(errors="replace").splitlines():
|
|
64
|
+
line = raw.strip()
|
|
65
|
+
if line.startswith("[") and line.endswith("]"):
|
|
66
|
+
section = line[1:-1].strip()
|
|
67
|
+
if section.startswith("remote "):
|
|
68
|
+
# [remote "origin"] -> origin
|
|
69
|
+
current_remote = section.split('"')[1] if '"' in section else section[7:].strip()
|
|
70
|
+
else:
|
|
71
|
+
current_remote = None
|
|
72
|
+
continue
|
|
73
|
+
if current_remote and "=" in line:
|
|
74
|
+
key, _, value = line.partition("=")
|
|
75
|
+
if key.strip().lower() == "url" and value.strip():
|
|
76
|
+
remotes[current_remote] = normalize_remote_url(value.strip())
|
|
77
|
+
|
|
78
|
+
return remotes.get("origin") or next(iter(remotes.values()), None)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def read_current_branch(git_root: Path) -> str | None:
|
|
82
|
+
"""Return the checked-out branch name, or None if detached."""
|
|
83
|
+
head = git_root / ".git" / "HEAD"
|
|
84
|
+
if not head.exists():
|
|
85
|
+
return None
|
|
86
|
+
text = head.read_text(errors="replace").strip()
|
|
87
|
+
if text.startswith("ref:"):
|
|
88
|
+
# ref: refs/heads/main -> main
|
|
89
|
+
return text.split("refs/heads/", 1)[-1] if "refs/heads/" in text else None
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def slugify(name: str) -> str:
|
|
94
|
+
"""Derive a valid orkestr project slug from a directory name.
|
|
95
|
+
|
|
96
|
+
Slugs must match ^[a-z0-9][a-z0-9-]*$ and be 2-100 chars. Lowercases,
|
|
97
|
+
replaces runs of non-alphanumerics with a single hyphen, trims hyphens,
|
|
98
|
+
and pads to the 2-char minimum.
|
|
99
|
+
"""
|
|
100
|
+
slug = re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-")
|
|
101
|
+
slug = re.sub(r"-{2,}", "-", slug)
|
|
102
|
+
if not slug:
|
|
103
|
+
slug = "app"
|
|
104
|
+
if not slug[0].isalnum():
|
|
105
|
+
slug = "a" + slug
|
|
106
|
+
if len(slug) < 2:
|
|
107
|
+
slug = (slug + "-app")[:100]
|
|
108
|
+
return slug[:100]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Project-local config: ./.orkestr/config.json.
|
|
2
|
+
|
|
3
|
+
`orkestr init` writes this file to tie the current directory to an orkestr
|
|
4
|
+
project, so `orkestr deploy .` knows what "." means. It is gitignored
|
|
5
|
+
(local-only, per-developer) — distinct from the global ~/.orkestr/config.json
|
|
6
|
+
that holds credentials and the API URL.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
LOCAL_DIR_NAME = ".orkestr"
|
|
13
|
+
LOCAL_FILE_NAME = "config.json"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def local_dir(root: Path | None = None) -> Path:
|
|
17
|
+
return (root or Path.cwd()) / LOCAL_DIR_NAME
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def find_local_config(start: Path | None = None) -> Path | None:
|
|
21
|
+
"""Walk up from start (default cwd) to find a .orkestr/config.json."""
|
|
22
|
+
path = (start or Path.cwd()).resolve()
|
|
23
|
+
for candidate in [path, *path.parents]:
|
|
24
|
+
cfg = candidate / LOCAL_DIR_NAME / LOCAL_FILE_NAME
|
|
25
|
+
if cfg.exists():
|
|
26
|
+
return cfg
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def load_local(start: Path | None = None) -> dict | None:
|
|
31
|
+
"""Load the nearest project-local config, or None if there isn't one."""
|
|
32
|
+
path = find_local_config(start)
|
|
33
|
+
if not path:
|
|
34
|
+
return None
|
|
35
|
+
try:
|
|
36
|
+
return json.loads(path.read_text())
|
|
37
|
+
except (json.JSONDecodeError, OSError):
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def write_local(data: dict, root: Path | None = None) -> Path:
|
|
42
|
+
"""Write .orkestr/config.json under root (default cwd) and gitignore it."""
|
|
43
|
+
root = root or Path.cwd()
|
|
44
|
+
directory = local_dir(root)
|
|
45
|
+
directory.mkdir(parents=True, exist_ok=True)
|
|
46
|
+
path = directory / LOCAL_FILE_NAME
|
|
47
|
+
path.write_text(json.dumps(data, indent=2) + "\n")
|
|
48
|
+
_ensure_gitignored(root)
|
|
49
|
+
return path
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _ensure_gitignored(root: Path) -> None:
|
|
53
|
+
"""Add `.orkestr/` to the repo's .gitignore if not already ignored."""
|
|
54
|
+
gitignore = root / ".gitignore"
|
|
55
|
+
entry = f"{LOCAL_DIR_NAME}/"
|
|
56
|
+
lines = gitignore.read_text().splitlines() if gitignore.exists() else []
|
|
57
|
+
if any(line.strip() in (entry, LOCAL_DIR_NAME) for line in lines):
|
|
58
|
+
return
|
|
59
|
+
with gitignore.open("a") as f:
|
|
60
|
+
if lines and lines[-1].strip():
|
|
61
|
+
f.write("\n")
|
|
62
|
+
f.write(f"# orkestr CLI local project config\n{entry}\n")
|