ermes-cli 1.2.1__tar.gz → 1.3.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.
Files changed (73) hide show
  1. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/PKG-INFO +1 -1
  2. ermes_cli-1.3.0/ermes_cli/__init__.py +1 -0
  3. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/main.py +1 -1
  4. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/update.py +32 -11
  5. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/pyproject.toml +1 -1
  6. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_update.py +41 -1
  7. ermes_cli-1.2.1/ermes_cli/__init__.py +0 -1
  8. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/.gitignore +0 -0
  9. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/README.md +0 -0
  10. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/admin_api.py +0 -0
  11. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/auth0.py +0 -0
  12. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/client.py +0 -0
  13. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/__init__.py +0 -0
  14. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/auth_cmds.py +0 -0
  15. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/campaigns.py +0 -0
  16. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/config_cmd.py +0 -0
  17. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/data_paths.py +0 -0
  18. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/export.py +0 -0
  19. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/ingest.py +0 -0
  20. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/journeys.py +0 -0
  21. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/keys.py +0 -0
  22. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/lists.py +0 -0
  23. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/metrics.py +0 -0
  24. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/projects.py +0 -0
  25. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/providers.py +0 -0
  26. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/skill.py +0 -0
  27. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/subscriptions.py +0 -0
  28. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/tags.py +0 -0
  29. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/templates.py +0 -0
  30. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/users.py +0 -0
  31. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/commands/write_cmds.py +0 -0
  32. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/config.py +0 -0
  33. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/errors.py +0 -0
  34. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/export_utils.py +0 -0
  35. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/keyring_store.py +0 -0
  36. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/output.py +0 -0
  37. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/rules.py +0 -0
  38. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/skill/SKILL.md +0 -0
  39. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/ermes_cli/write_mode.py +0 -0
  40. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/scripts/install-cli.sh +0 -0
  41. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/__init__.py +0 -0
  42. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/conftest.py +0 -0
  43. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_admin_api.py +0 -0
  44. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_auth0.py +0 -0
  45. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_auth_cmds.py +0 -0
  46. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_client.py +0 -0
  47. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/__init__.py +0 -0
  48. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_campaigns.py +0 -0
  49. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_data_paths.py +0 -0
  50. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_export.py +0 -0
  51. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_ingest.py +0 -0
  52. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_journeys.py +0 -0
  53. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_keys.py +0 -0
  54. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_lists.py +0 -0
  55. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_metrics.py +0 -0
  56. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_projects.py +0 -0
  57. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_projects_list.py +0 -0
  58. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_providers.py +0 -0
  59. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_subscriptions.py +0 -0
  60. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_tags.py +0 -0
  61. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_templates.py +0 -0
  62. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_commands/test_users.py +0 -0
  63. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_config.py +0 -0
  64. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_export_utils.py +0 -0
  65. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_keyring_store.py +0 -0
  66. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_output.py +0 -0
  67. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_projects_config.py +0 -0
  68. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_rules.py +0 -0
  69. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_skill_command.py +0 -0
  70. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_version.py +0 -0
  71. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_whoami.py +0 -0
  72. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_write_cmds.py +0 -0
  73. {ermes_cli-1.2.1 → ermes_cli-1.3.0}/tests/test_write_mode.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: ermes-cli
3
- Version: 1.2.1
3
+ Version: 1.3.0
4
4
  Summary: CLI-first access to Ermes marketing automation with Auth0 multi-project auth.
5
5
  Project-URL: Homepage, https://ermes.publinker.com
6
6
  Project-URL: Repository, https://github.com/Martech-DM/ermes
@@ -0,0 +1 @@
1
+ __version__ = "1.3.0"
@@ -70,7 +70,7 @@ def update(
70
70
  check: bool = typer.Option(False, "--check", help="Only report whether a newer version exists."),
71
71
  yes: bool = typer.Option(False, "--yes", "-y", help="Upgrade without asking."),
72
72
  ):
73
- """Check PyPI for a newer ermes-cli and upgrade the pipx install. Disable the daily prompt with ERMES_NO_UPDATE_CHECK=1."""
73
+ """Check PyPI for a newer ermes-cli and upgrade the pipx install. Disable the update prompt with ERMES_NO_UPDATE_CHECK=1."""
74
74
  import json
75
75
  import time
76
76
 
@@ -1,8 +1,9 @@
1
1
  """Newer-version check, upgrade prompt and `ermes update` (DEV-1972).
2
2
 
3
3
  ermes-cli ships to PyPI on `ermes-cli-v*` tags (DEV-2262), so "latest" is PyPI's current
4
- `ermes-cli` release: a public JSON endpoint, no GitHub or Ermes credentials. Interactive runs check
5
- at most once a day and ask before upgrading, like Codex / Claude Code. Only the pipx install made by
4
+ `ermes-cli` release: a public JSON endpoint, no GitHub or Ermes credentials. Like Codex, interactive
5
+ runs only read the cached answer and refresh it in a detached child every few hours, so a command
6
+ never waits on PyPI and a new release prompts from the next run on (DEV-2343). Only the pipx install made by
6
7
  `install-cli.sh` is upgraded in place (`pipx upgrade`); anything else gets the manual command.
7
8
  """
8
9
 
@@ -28,8 +29,8 @@ PACKAGE = "ermes-cli"
28
29
  PYPI_URL = f"https://pypi.org/pypi/{PACKAGE}/json"
29
30
 
30
31
  CACHE_FILE = "update-check.json"
31
- CHECK_INTERVAL_S = 24 * 3600
32
- AUTO_TIMEOUT_S = 2.0
32
+ CHECK_INTERVAL_S = 4 * 3600
33
+ AUTO_TIMEOUT_S = 10.0 # in the background child, so it never delays a command
33
34
  EXPLICIT_TIMEOUT_S = 10.0
34
35
  OPT_OUT_ENV = "ERMES_NO_UPDATE_CHECK"
35
36
  # Never prompt before these: `version` must stay a pure read, `update` does its own check.
@@ -174,21 +175,41 @@ def auto_check_enabled(use_json: bool, command: str | None) -> bool:
174
175
  return sys.stdin.isatty() and sys.stdout.isatty() and sys.stderr.isatty()
175
176
 
176
177
 
177
- def _cached_latest() -> str | None:
178
- cache = read_cache()
179
- if time.time() - float(cache.get("checked_at") or 0) < CHECK_INTERVAL_S:
180
- return cache.get("latest")
178
+ def refresh_cache() -> None:
179
+ """Ask PyPI and cache the answer. Failures are cached too, so an offline laptop backs off."""
181
180
  try:
182
181
  latest = fetch_latest(timeout=AUTO_TIMEOUT_S)
183
182
  except UpdateError as e:
184
183
  write_cache(checked_at=time.time(), latest=None, error=str(e))
185
- return None
184
+ return
186
185
  write_cache(checked_at=time.time(), latest=latest, error=None)
187
- return latest
186
+
187
+
188
+ def _refresh_in_background() -> None:
189
+ """Detached child: survives this command's exit and never touches its terminal.
190
+
191
+ `-I` keeps the current directory off sys.path, so an `ermes_cli/` folder where the operator
192
+ happens to run `ermes` cannot stand in for the installed package.
193
+ """
194
+ subprocess.Popen(
195
+ [sys.executable, "-I", "-c", "from ermes_cli.update import refresh_cache; refresh_cache()"],
196
+ stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
197
+ start_new_session=True, close_fds=True,
198
+ )
199
+
200
+
201
+ def _cached_latest() -> str | None:
202
+ """The cached latest, refreshed in the background when older than CHECK_INTERVAL_S."""
203
+ cache = read_cache()
204
+ if time.time() - float(cache.get("checked_at") or 0) >= CHECK_INTERVAL_S:
205
+ # Stamp first so concurrent runs do not each spawn a child; the child overwrites it.
206
+ write_cache(checked_at=time.time())
207
+ _refresh_in_background()
208
+ return read_cache().get("latest")
188
209
 
189
210
 
190
211
  def maybe_prompt(use_json: bool, command: str | None) -> None:
191
- """Ask (at most daily) whether to upgrade; on yes, upgrade and re-run the command on the new code.
212
+ """Ask whether to upgrade to the cached latest; on yes, upgrade and re-run the command on the new code.
192
213
 
193
214
  Never raises: a broken check must not break the command the operator actually asked for.
194
215
  """
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "ermes-cli"
7
7
  # Keep in lockstep with ermes_cli/__init__.py::__version__ — tests/test_version.py fails if they drift.
8
- version = "1.2.1"
8
+ version = "1.3.0"
9
9
  description = "CLI-first access to Ermes marketing automation with Auth0 multi-project auth."
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.10"
@@ -13,6 +13,7 @@ import pytest
13
13
  from ermes_cli import update as upd
14
14
 
15
15
  PYPI = upd.PYPI_URL
16
+ _REAL_REFRESH_IN_BACKGROUND = upd._refresh_in_background # before the autouse patch
16
17
 
17
18
 
18
19
  @pytest.fixture(autouse=True)
@@ -22,6 +23,8 @@ def _isolated(tmp_path, monkeypatch):
22
23
  monkeypatch.delenv("CI", raising=False)
23
24
  monkeypatch.setattr("ermes_cli.update.__version__", "1.0.0")
24
25
  monkeypatch.setattr("ermes_cli.main.__version__", "1.0.0")
26
+ # Run the background refresh inline so prompt tests see its answer; real spawn tested below.
27
+ monkeypatch.setattr(upd, "_refresh_in_background", upd.refresh_cache)
25
28
 
26
29
 
27
30
  def _pypi(httpx_mock, version="1.1.0"):
@@ -167,7 +170,7 @@ def test_skip_this_version_silences_it_until_a_newer_one(httpx_mock, interactive
167
170
  assert len(asked) == 2 and "1.2.0" in asked[1]
168
171
 
169
172
 
170
- def test_checks_pypi_at_most_once_a_day(httpx_mock, interactive, fake_install, monkeypatch):
173
+ def test_checks_pypi_at_most_once_per_interval(httpx_mock, interactive, fake_install, monkeypatch):
171
174
  _pypi(httpx_mock, "1.0.0")
172
175
  _answer(monkeypatch, "n")
173
176
  upd.maybe_prompt(False, "campaigns")
@@ -175,6 +178,43 @@ def test_checks_pypi_at_most_once_a_day(httpx_mock, interactive, fake_install, m
175
178
  assert len(httpx_mock.get_requests()) == 1
176
179
 
177
180
 
181
+ def test_stale_cache_refreshes_in_background_and_uses_the_saved_answer(interactive, fake_install, monkeypatch):
182
+ spawned = []
183
+ monkeypatch.setattr(upd, "_refresh_in_background", lambda: spawned.append(1))
184
+ upd.write_cache(checked_at=time.time() - upd.CHECK_INTERVAL_S - 1, latest="1.1.0")
185
+ asked = _answer(monkeypatch, "n")
186
+ upd.maybe_prompt(False, "campaigns")
187
+ upd.maybe_prompt(False, "campaigns") # stamped by the first run: no second child
188
+ assert spawned == [1] and len(asked) == 2 and "1.1.0" in asked[0]
189
+
190
+
191
+ def test_fresh_cache_spawns_nothing(interactive, fake_install, monkeypatch):
192
+ spawned = []
193
+ monkeypatch.setattr(upd, "_refresh_in_background", lambda: spawned.append(1))
194
+ upd.write_cache(checked_at=time.time(), latest="1.0.0")
195
+ upd.maybe_prompt(False, "campaigns")
196
+ assert spawned == []
197
+
198
+
199
+ def test_background_child_is_detached_and_silent(monkeypatch):
200
+ calls = []
201
+ monkeypatch.setattr(upd.subprocess, "Popen", lambda argv, **kw: calls.append((argv, kw)))
202
+ _REAL_REFRESH_IN_BACKGROUND()
203
+ argv, kw = calls[0]
204
+ assert argv[:3] == [sys.executable, "-I", "-c"] and "refresh_cache()" in argv[-1]
205
+ assert kw["start_new_session"] is True
206
+ assert kw["stdin"] is kw["stdout"] is kw["stderr"] is subprocess.DEVNULL
207
+
208
+
209
+ def test_refresh_cache_writes_latest_and_errors(httpx_mock):
210
+ _pypi(httpx_mock, "1.4.0")
211
+ upd.refresh_cache()
212
+ assert upd.read_cache()["latest"] == "1.4.0" and upd.read_cache()["error"] is None
213
+ httpx_mock.add_exception(httpx.ConnectError("offline"), url=PYPI)
214
+ upd.refresh_cache()
215
+ assert upd.read_cache()["latest"] is None and "ConnectError" in upd.read_cache()["error"]
216
+
217
+
178
218
  def test_lookup_failure_is_cached_and_silent(httpx_mock, interactive, fake_install, monkeypatch, capsys):
179
219
  httpx_mock.add_exception(httpx.ConnectError("offline"), url=PYPI)
180
220
  asked = _answer(monkeypatch, "y")
@@ -1 +0,0 @@
1
- __version__ = "1.2.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes