viur-cli 2.3.4__tar.gz → 2.3.6__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 (29) hide show
  1. {viur_cli-2.3.4/src/viur_cli.egg-info → viur_cli-2.3.6}/PKG-INFO +1 -1
  2. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/scriptor/cli.py +77 -13
  3. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/version.py +1 -1
  4. {viur_cli-2.3.4 → viur_cli-2.3.6/src/viur_cli.egg-info}/PKG-INFO +1 -1
  5. {viur_cli-2.3.4 → viur_cli-2.3.6}/LICENSE +0 -0
  6. {viur_cli-2.3.4 → viur_cli-2.3.6}/README.md +0 -0
  7. {viur_cli-2.3.4 → viur_cli-2.3.6}/pyproject.toml +0 -0
  8. {viur_cli-2.3.4 → viur_cli-2.3.6}/setup.cfg +0 -0
  9. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/__init__.py +0 -0
  10. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/build.py +0 -0
  11. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/cli.py +0 -0
  12. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/cloud.py +0 -0
  13. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/conf.py +0 -0
  14. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/deprecated.py +0 -0
  15. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/local.py +0 -0
  16. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/package.py +0 -0
  17. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/scriptor/__init__.py +0 -0
  18. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/scriptor/login.py +0 -0
  19. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/scripts/__init__.py +0 -0
  20. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/scripts/get_pyodide.py +0 -0
  21. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/setup.py +0 -0
  22. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/tool.py +0 -0
  23. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/update.py +0 -0
  24. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli/utils.py +0 -0
  25. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli.egg-info/SOURCES.txt +0 -0
  26. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli.egg-info/dependency_links.txt +0 -0
  27. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli.egg-info/entry_points.txt +0 -0
  28. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli.egg-info/requires.txt +0 -0
  29. {viur_cli-2.3.4 → viur_cli-2.3.6}/src/viur_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: viur-cli
3
- Version: 2.3.4
3
+ Version: 2.3.6
4
4
  Summary: Command-line interface for ViUR application maintenance.
5
5
  Author-email: "Andreas H. Kelch" <ak@mausbrand.de>
6
6
  License-Expression: MIT
@@ -4,6 +4,7 @@ import json
4
4
  import requests
5
5
  import os
6
6
  import hashlib
7
+ import difflib
7
8
  import asyncio
8
9
  import sys
9
10
  import glob
@@ -36,22 +37,39 @@ def script():
36
37
 
37
38
 
38
39
  @script.command()
39
- @click.option('--url', default=None, help='Set the url')
40
+ @click.option('--url', default=None, help='Set the server url')
40
41
  @click.option('--username', default=None, help='Set the username')
41
42
  @click.option('--working_dir', default=None, help='Set the working directory where scripts are stored to')
42
43
  def configure(url: str, username: str, working_dir: str):
43
44
  """
44
45
  Manage configuration settings.
45
46
  """
47
+ if not any([url, username, working_dir]):
48
+ click.echo("No parameters provided. Use one or more of the following options:")
49
+ click.echo(" --url Set the server URL")
50
+ click.echo(" --username Set the username")
51
+ click.echo(" --working_dir Set the working directory where scripts are stored to")
52
+ return
53
+
54
+ changed = []
46
55
 
47
56
  if url:
48
57
  scriptor_config["base_url"] = url
58
+ changed.append(f"url = {url}")
49
59
 
50
60
  if username:
51
61
  scriptor_config["username"] = username
62
+ changed.append(f"username = {username}")
52
63
 
53
64
  if working_dir:
54
65
  scriptor_config["working_dir"] = working_dir.replace("\\", "/")
66
+ changed.append(f"working_dir = {working_dir}")
67
+
68
+ click.echo("Configuration updated:")
69
+ for entry in changed:
70
+ click.echo(f" {entry}")
71
+
72
+ scriptor_config.save()
55
73
 
56
74
 
57
75
  @script.command()
@@ -111,7 +129,8 @@ def check_session(ctx: click.Context):
111
129
  get_modules()
112
130
 
113
131
  @script.command()
114
- @click.option('--force', default=False, help='Force replace files from server in local working directory')
132
+ @click.option('--force', default=False, is_flag=True,
133
+ help='Overwrite local files without asking for confirmation')
115
134
  @click.pass_context
116
135
  def pull(ctx: click.Context, force: bool):
117
136
  """
@@ -125,36 +144,74 @@ def pull(ctx: click.Context, force: bool):
125
144
  tree = await modules.get_module("script")
126
145
  working_dir = scriptor_config.get("working_dir")
127
146
 
147
+ stats = {"new": 0, "updated": 0, "skipped": 0, "unchanged": 0, "dirs": 0}
148
+
128
149
  async def process_entry(entry: dict, is_node: bool):
129
150
  _path = os.path.join(working_dir, entry["path"].lstrip("/"))
130
151
 
131
152
  if is_node:
132
153
  if not os.path.exists(_path):
154
+ click.echo(click.style(f" mkdir {entry['path']}", fg="blue"))
133
155
  os.makedirs(_path)
156
+ stats["dirs"] += 1
134
157
  else:
158
+ click.echo(f" check {entry['path']}", nl=False)
159
+
135
160
  def create_file():
136
161
  with open(_path, "a+") as f:
137
162
  f.write(entry["script"])
138
163
 
139
- click.echo(f"Pull {_path}")
140
-
141
164
  if os.path.exists(_path):
142
165
  if force:
166
+ with open(_path, "r") as f:
167
+ changed = f.read().splitlines() != entry["script"].splitlines()
143
168
  os.remove(_path)
144
169
  create_file()
170
+ if changed:
171
+ click.echo(click.style(" [updated]", fg="yellow"))
172
+ stats["updated"] += 1
173
+ else:
174
+ click.echo(click.style(" [ok]", fg="green"))
175
+ stats["unchanged"] += 1
145
176
  else:
146
177
  with open(_path, "r") as f:
147
- if hashlib.sha256(entry["script"].encode()).digest() \
148
- != hashlib.sha256(f.read().encode()).digest():
149
- try:
150
- if click.confirm(f"There is a difference with {entry['path']}. Overwrite?"):
151
- os.remove(_path)
152
- create_file()
153
- except click.exceptions.Abort:
154
- click.echo("\nSkipping...")
155
-
178
+ local_content = f.read()
179
+ remote_content = entry["script"]
180
+ diff = list(difflib.unified_diff(
181
+ remote_content.splitlines(),
182
+ local_content.splitlines(),
183
+ fromfile=f"server/{entry['path'].lstrip('/')}",
184
+ tofile=f"local/{entry['path'].lstrip('/')}",
185
+ lineterm="",
186
+ ))
187
+ if diff:
188
+ click.echo(click.style(" [diff]", fg="yellow"))
189
+ for line in diff:
190
+ if line.startswith("+++") or line.startswith("---"):
191
+ click.echo(click.style(line, bold=True))
192
+ elif line.startswith("@@"):
193
+ click.echo(click.style(line, fg="cyan"))
194
+ elif line.startswith("+"):
195
+ click.echo(click.style(line, fg="green"))
196
+ elif line.startswith("-"):
197
+ click.echo(click.style(line, fg="red"))
198
+ else:
199
+ click.echo(line)
200
+ if click.confirm(f"Overwrite local {entry['path']} with remote version?"):
201
+ os.remove(_path)
202
+ create_file()
203
+ stats["updated"] += 1
204
+ else:
205
+ stats["skipped"] += 1
206
+ else:
207
+ click.echo(click.style(" [ok]", fg="green"))
208
+ stats["unchanged"] += 1
156
209
  else:
210
+ click.echo(click.style(" [new]", fg="green"))
157
211
  create_file()
212
+ stats["new"] += 1
213
+
214
+ click.echo("Fetching scripts from server...")
158
215
 
159
216
  # Process nodes first
160
217
  async for node in tree.list(skel_type="node"):
@@ -164,6 +221,13 @@ def pull(ctx: click.Context, force: bool):
164
221
  async for leaf in tree.list(skel_type="leaf"):
165
222
  await process_entry(leaf, False)
166
223
 
224
+ click.echo("")
225
+ click.echo(click.style("Summary:", bold=True))
226
+ click.echo(f" new: {stats['new']}")
227
+ click.echo(f" updated: {stats['updated']}")
228
+ click.echo(f" skipped: {stats['skipped']}")
229
+ click.echo(f" unchanged: {stats['unchanged']}")
230
+
167
231
  asyncio.run(main())
168
232
 
169
233
 
@@ -1,2 +1,2 @@
1
- __version__ = "2.3.4"
1
+ __version__ = "2.3.6"
2
2
  MINIMAL_PIPENV = "2023.11.15"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: viur-cli
3
- Version: 2.3.4
3
+ Version: 2.3.6
4
4
  Summary: Command-line interface for ViUR application maintenance.
5
5
  Author-email: "Andreas H. Kelch" <ak@mausbrand.de>
6
6
  License-Expression: MIT
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