viur-cli 2.3.8__tar.gz → 2.3.10__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.
- {viur_cli-2.3.8/src/viur_cli.egg-info → viur_cli-2.3.10}/PKG-INFO +1 -1
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/scriptor/cli.py +47 -10
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/scriptor/login.py +1 -1
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/version.py +1 -1
- {viur_cli-2.3.8 → viur_cli-2.3.10/src/viur_cli.egg-info}/PKG-INFO +1 -1
- {viur_cli-2.3.8 → viur_cli-2.3.10}/LICENSE +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/README.md +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/pyproject.toml +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/setup.cfg +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/__init__.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/build.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/cli.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/cloud.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/conf.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/deprecated.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/local.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/package.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/scriptor/__init__.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/scripts/__init__.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/scripts/get_pyodide.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/setup.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/tool.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/update.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli/utils.py +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli.egg-info/SOURCES.txt +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli.egg-info/dependency_links.txt +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli.egg-info/entry_points.txt +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli.egg-info/requires.txt +0 -0
- {viur_cli-2.3.8 → viur_cli-2.3.10}/src/viur_cli.egg-info/top_level.txt +0 -0
|
@@ -3,7 +3,6 @@ import click
|
|
|
3
3
|
import json
|
|
4
4
|
import requests
|
|
5
5
|
import os
|
|
6
|
-
import hashlib
|
|
7
6
|
import difflib
|
|
8
7
|
import asyncio
|
|
9
8
|
import sys
|
|
@@ -29,6 +28,34 @@ def get_modules():
|
|
|
29
28
|
return _modules
|
|
30
29
|
|
|
31
30
|
|
|
31
|
+
def normalize_path(path: str | None) -> str:
|
|
32
|
+
"""
|
|
33
|
+
Normalize a tree path for comparison.
|
|
34
|
+
|
|
35
|
+
The server stores node and leaf paths without surrounding slashes, whereas paths
|
|
36
|
+
derived from the local working directory may carry a leading or trailing slash.
|
|
37
|
+
|
|
38
|
+
:param path: The path to normalize, may be ``None``.
|
|
39
|
+
:return: The path without leading or trailing slashes.
|
|
40
|
+
"""
|
|
41
|
+
return (path or "").strip("/")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def scripts_differ(remote: str | None, local: str | None) -> bool:
|
|
45
|
+
"""
|
|
46
|
+
Compare a remote and a local script, ignoring differing line endings.
|
|
47
|
+
|
|
48
|
+
Scripts edited in the browser are stored with CRLF, whereas local files usually use
|
|
49
|
+
LF. Comparing them line by line -- as ``pull`` already does -- keeps both commands
|
|
50
|
+
from reporting a file as modified just because of its line endings.
|
|
51
|
+
|
|
52
|
+
:param remote: The script as stored on the server, may be ``None``.
|
|
53
|
+
:param local: The script as read from the working directory, may be ``None``.
|
|
54
|
+
:return: True if the scripts differ in anything but their line endings.
|
|
55
|
+
"""
|
|
56
|
+
return (remote or "").splitlines() != (local or "").splitlines()
|
|
57
|
+
|
|
58
|
+
|
|
32
59
|
@cli.group()
|
|
33
60
|
def script():
|
|
34
61
|
"""
|
|
@@ -164,7 +191,7 @@ def pull(ctx: click.Context, force: bool):
|
|
|
164
191
|
if os.path.exists(_path):
|
|
165
192
|
if force:
|
|
166
193
|
with open(_path, "r") as f:
|
|
167
|
-
changed =
|
|
194
|
+
changed = scripts_differ(entry["script"], f.read())
|
|
168
195
|
os.remove(_path)
|
|
169
196
|
create_file()
|
|
170
197
|
if changed:
|
|
@@ -265,8 +292,6 @@ def push(ctx: click.Context, force: bool, watch: bool):
|
|
|
265
292
|
if not working_dir.endswith("/"):
|
|
266
293
|
tmp += "/"
|
|
267
294
|
file = file.removeprefix(tmp)
|
|
268
|
-
if _type == "node":
|
|
269
|
-
file += "/"
|
|
270
295
|
|
|
271
296
|
is_root = False
|
|
272
297
|
parent = parent.removeprefix(tmp).removeprefix(working_dir.replace("/", ""))
|
|
@@ -277,7 +302,7 @@ def push(ctx: click.Context, force: bool, watch: bool):
|
|
|
277
302
|
# Search for the entry with the given path
|
|
278
303
|
entry = None
|
|
279
304
|
async for item in tree.list(skel_type=_type):
|
|
280
|
-
if item.get("path") == file:
|
|
305
|
+
if normalize_path(item.get("path")) == normalize_path(file):
|
|
281
306
|
entry = item
|
|
282
307
|
break
|
|
283
308
|
|
|
@@ -287,8 +312,7 @@ def push(ctx: click.Context, force: bool, watch: bool):
|
|
|
287
312
|
with open(_real_file, "r") as f:
|
|
288
313
|
file_content = f.read()
|
|
289
314
|
|
|
290
|
-
if
|
|
291
|
-
!= hashlib.sha256(file_content.encode("utf-8")).digest():
|
|
315
|
+
if scripts_differ(entry["script"], file_content):
|
|
292
316
|
can_push = force
|
|
293
317
|
if not can_push:
|
|
294
318
|
can_push = click.confirm(f"Content of {file} changed. Overwrite?")
|
|
@@ -317,18 +341,31 @@ def push(ctx: click.Context, force: bool, watch: bool):
|
|
|
317
341
|
root_node_entry = node
|
|
318
342
|
break
|
|
319
343
|
|
|
320
|
-
if
|
|
321
|
-
|
|
344
|
+
if root_node_entry is None:
|
|
345
|
+
click.echo(click.style(
|
|
346
|
+
"Unable to determine the root node of the script tree. "
|
|
347
|
+
"Make sure the server is reachable and the session is still valid, "
|
|
348
|
+
"otherwise run `viur script setup` again.",
|
|
349
|
+
fg="red"
|
|
350
|
+
))
|
|
351
|
+
return
|
|
322
352
|
|
|
323
353
|
parent_entry = root_node_entry
|
|
324
354
|
if not is_root:
|
|
325
355
|
# Find parent entry
|
|
326
356
|
parent_entry = None
|
|
327
357
|
async for node in tree.list(skel_type="node"):
|
|
328
|
-
if node.get("path") == parent:
|
|
358
|
+
if normalize_path(node.get("path")) == normalize_path(parent):
|
|
329
359
|
parent_entry = node
|
|
330
360
|
break
|
|
331
361
|
|
|
362
|
+
if parent_entry is None:
|
|
363
|
+
click.echo(click.style(
|
|
364
|
+
f"Skipping {file}, because its parent folder {parent} does not exist on the server.",
|
|
365
|
+
fg="red"
|
|
366
|
+
))
|
|
367
|
+
continue
|
|
368
|
+
|
|
332
369
|
last = file
|
|
333
370
|
if file.count("/") > 0:
|
|
334
371
|
_split = [_f for _f in file.split("/") if _f]
|
|
@@ -49,7 +49,7 @@ def ensure_login(
|
|
|
49
49
|
|
|
50
50
|
cookie_str: str = callback_app.cookie.get()
|
|
51
51
|
key, value = cookie_str.split(";", 1)[0].split("=")
|
|
52
|
-
scriptor_config.
|
|
52
|
+
scriptor_config.setdefault("cookies", {})[key] = value
|
|
53
53
|
scriptor_config.save()
|
|
54
54
|
|
|
55
55
|
return True
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "2.3.
|
|
1
|
+
__version__ = "2.3.10"
|
|
2
2
|
MINIMAL_PIPENV = "2023.11.15"
|
|
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
|
|
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
|