Install Pipelines natively by default on macOS and Linux
Add scripts/setup-native.py and make ./install (and --native) build the server, the CLI and ntfy from source into ~/.local/share/pipelines, detect an existing host OpenCode and Pi instead of installing them, install the packaged authoring skill, migrate an existing Docker database and ntfy auth store, save the host client default and start both services. ./install --docker keeps the previous Docker server + ntfy installation unchanged. ntfy is compiled from its pinned Go module on every host because upstream publishes no macOS server binary (its darwin asset is built with -tags noserver); its cgo SQLite driver is why a C compiler is now required natively. The ntfy credential bootstrap and the client default writer are shared by both installers, installation.Load resolves symlinked prefixes, the Docker migration copies the SQLite write-ahead log so the newest definitions and runs are not lost, and the account subcommands read the generated configuration through NTFY_CONFIG_FILE. Verified on macOS: 115 Python tests, go build/vet/test, and scratch installs that migrate 9 pipelines and 31 runs, build ntfy v2.30.0 and start both services healthy on spare ports before stopping them.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
@@ -52,6 +53,35 @@ class ConfigureTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as directory, self.assertRaises(ValueError):
|
||||
configure.configure(directory, "https://example.com", "0.0.0.0\nEVIL=yes", "Europe/London")
|
||||
|
||||
def test_client_default_is_saved_privately_and_preserves_other_keys(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
environ = {"XDG_CONFIG_HOME": directory}
|
||||
path = configure.configure_client("ws://127.0.0.1:8080/connect", environ)
|
||||
self.assertEqual(path, Path(directory) / "pipelines/client.json")
|
||||
self.assertEqual(path.stat().st_mode & 0o777, 0o600)
|
||||
self.assertEqual(json.loads(path.read_text())["server_url"], "ws://127.0.0.1:8080/connect")
|
||||
# Unrelated keys survive a later reinstall with a different address.
|
||||
path.write_text(json.dumps({"server_url": "ws://old/connect", "theme": "dark"}))
|
||||
configure.configure_client("ws://127.0.0.1:9090/connect", environ)
|
||||
saved = json.loads(path.read_text())
|
||||
self.assertEqual(saved["server_url"], "ws://127.0.0.1:9090/connect")
|
||||
self.assertEqual(saved["theme"], "dark")
|
||||
|
||||
def test_client_default_refuses_symlink_and_non_object(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
environ = {"XDG_CONFIG_HOME": directory}
|
||||
target = Path(directory) / "real.json"
|
||||
target.write_text("{}")
|
||||
directory_path = Path(directory) / "pipelines"
|
||||
directory_path.mkdir()
|
||||
(directory_path / "client.json").symlink_to(target)
|
||||
with self.assertRaisesRegex(ValueError, "symlinked client.json"):
|
||||
configure.configure_client("ws://127.0.0.1:8080/connect", environ)
|
||||
(directory_path / "client.json").unlink()
|
||||
(directory_path / "client.json").write_text("[]")
|
||||
with self.assertRaisesRegex(ValueError, "must contain an object"):
|
||||
configure.configure_client("ws://127.0.0.1:8080/connect", environ)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user