viur-cli 2.1.0__tar.gz → 2.2.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.
- {viur_cli-2.1.0/src/viur_cli.egg-info → viur_cli-2.2.0}/PKG-INFO +4 -2
- {viur_cli-2.1.0 → viur_cli-2.2.0}/setup.cfg +1 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/cli.py +69 -14
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/utils.py +4 -1
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/version.py +1 -1
- {viur_cli-2.1.0 → viur_cli-2.2.0/src/viur_cli.egg-info}/PKG-INFO +4 -2
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli.egg-info/requires.txt +1 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/LICENSE +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/README.md +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/pyproject.toml +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/setup.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/__init__.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/build.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/cli.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/cloud.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/conf.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/deprecated.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/local.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/package.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/__init__.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/__init__.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/csvwriter.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/dialog.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/logger.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/module.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/network.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/progressbar.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/readers.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/utils.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/viur.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scriptor/scriptor/writer.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scripts/__init__.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/scripts/get_pyodide.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/setup.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/tool.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli/update.py +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli.egg-info/SOURCES.txt +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli.egg-info/dependency_links.txt +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli.egg-info/entry_points.txt +0 -0
- {viur_cli-2.1.0 → viur_cli-2.2.0}/src/viur_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: viur_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Command-line interface for ViUR application maintenance.
|
|
5
5
|
Home-page: https://github.com/viur-framework/viur-cli
|
|
6
6
|
Author: Andreas H. Kelch
|
|
@@ -17,6 +17,8 @@ Requires-Dist: click~=8.1.7
|
|
|
17
17
|
Requires-Dist: pipfile-requirements~=0.3
|
|
18
18
|
Requires-Dist: requests~=2.0
|
|
19
19
|
Requires-Dist: semver~=3.0
|
|
20
|
+
Requires-Dist: watchdog~=6.0
|
|
21
|
+
Dynamic: license-file
|
|
20
22
|
|
|
21
23
|
<div align="center">
|
|
22
24
|
<img src="https://github.com/viur-framework/viur-artwork/raw/main/icons/icon-cli.svg" height="196" alt="A hexagonal logo of the viur-cli" title="viur-cli">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import datetime
|
|
1
2
|
import click
|
|
2
3
|
import json
|
|
3
4
|
import requests
|
|
@@ -180,25 +181,29 @@ def pull(ctx: click.Context, force: bool):
|
|
|
180
181
|
@script.command()
|
|
181
182
|
@click.option('--force', '-f', is_flag=True, default=False,
|
|
182
183
|
help='Force push files from the local working directory onto the server')
|
|
184
|
+
@click.option('--watch', '-w', is_flag=True, default=False,
|
|
185
|
+
help="Watch for file changes in the script folder and push them to the server")
|
|
183
186
|
@click.pass_context
|
|
184
|
-
def push(ctx: click.Context, force: bool):
|
|
187
|
+
def push(ctx: click.Context, force: bool, watch: bool):
|
|
185
188
|
"""
|
|
186
189
|
Push contents of working_dir to server.
|
|
187
190
|
"""
|
|
191
|
+
|
|
188
192
|
check_session(ctx)
|
|
189
193
|
Request.COOKIES = cookiejar_from_dict(Config().get("cookies", {}))
|
|
190
194
|
|
|
191
195
|
from .scriptor.module import TreeModule
|
|
192
196
|
tree = TreeModule("script")
|
|
193
197
|
|
|
194
|
-
async def main():
|
|
198
|
+
async def main(file_path: str=None):
|
|
195
199
|
await tree.structure("node")
|
|
196
|
-
|
|
197
200
|
working_dir = Config().get("working_dir")
|
|
198
201
|
_files = glob.glob(f"{working_dir}/**/*", recursive=True)
|
|
199
|
-
|
|
200
202
|
for file in _files:
|
|
201
203
|
_real_file = file
|
|
204
|
+
if file_path and file_path != _real_file:
|
|
205
|
+
# only push a single file
|
|
206
|
+
continue
|
|
202
207
|
parent = os.path.dirname(file)
|
|
203
208
|
_type = "leaf"
|
|
204
209
|
if os.path.isdir(file):
|
|
@@ -224,27 +229,27 @@ def push(ctx: click.Context, force: bool):
|
|
|
224
229
|
|
|
225
230
|
if hashlib.sha256(entry["script"].encode("utf-8")).digest() \
|
|
226
231
|
!= hashlib.sha256(file_content.encode("utf-8")).digest():
|
|
227
|
-
|
|
228
|
-
if not
|
|
229
|
-
|
|
232
|
+
can_push = force
|
|
233
|
+
if not can_push:
|
|
234
|
+
can_push = click.confirm(f"Content of {file} changed. Overwrite?")
|
|
230
235
|
|
|
231
|
-
if
|
|
232
|
-
|
|
236
|
+
if can_push:
|
|
237
|
+
date = datetime.datetime.now().strftime("%H:%M:%S")
|
|
238
|
+
click.echo(f"{date if watch else ""} Push {_real_file}")
|
|
233
239
|
await tree.edit(_type, entry["key"], {
|
|
234
240
|
"script": file_content
|
|
235
241
|
})
|
|
236
242
|
|
|
237
243
|
except StopAsyncIteration:
|
|
238
|
-
_state = False
|
|
239
244
|
text = "folder"
|
|
240
245
|
if _type == "leaf":
|
|
241
246
|
text = "file"
|
|
242
247
|
|
|
243
|
-
|
|
244
|
-
if not
|
|
245
|
-
|
|
248
|
+
can_push = force
|
|
249
|
+
if not can_push:
|
|
250
|
+
can_push = click.confirm(f"There is no {text} named {file}. Create it?")
|
|
246
251
|
|
|
247
|
-
if
|
|
252
|
+
if can_push:
|
|
248
253
|
root_node_entry = (await tree.list_root_nodes())[0]
|
|
249
254
|
|
|
250
255
|
if not parent.endswith("/"):
|
|
@@ -286,6 +291,56 @@ def push(ctx: click.Context, force: bool):
|
|
|
286
291
|
click.echo(f"Push {_real_file}")
|
|
287
292
|
await tree.add(_type, args)
|
|
288
293
|
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
if watch:
|
|
297
|
+
print("Watching...")
|
|
298
|
+
def watch_loop():
|
|
299
|
+
from watchdog.events import RegexMatchingEventHandler
|
|
300
|
+
from watchdog.observers import Observer
|
|
301
|
+
import time
|
|
302
|
+
modified_files = {}
|
|
303
|
+
def on_modified(event):
|
|
304
|
+
try:
|
|
305
|
+
# check for tmp file
|
|
306
|
+
if event.src_path.endswith("~"):
|
|
307
|
+
return
|
|
308
|
+
if event.src_path not in modified_files:
|
|
309
|
+
modified_files[event.src_path] = os.path.getmtime(event.src_path)
|
|
310
|
+
elif os.path.getmtime(event.src_path) == modified_files[event.src_path]:
|
|
311
|
+
return
|
|
312
|
+
modified_files[event.src_path] = os.path.getmtime(event.src_path)
|
|
313
|
+
asyncio.new_event_loop().run_until_complete(main(event.src_path))
|
|
314
|
+
except Exception as e:
|
|
315
|
+
print(f"Error: on file {event.src_path} {e}")
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
regexes = [r".*\.py"]
|
|
319
|
+
ignore_regexes = []
|
|
320
|
+
ignore_directories = True
|
|
321
|
+
case_sensitive = False
|
|
322
|
+
event_handler = RegexMatchingEventHandler(
|
|
323
|
+
regexes=regexes,
|
|
324
|
+
ignore_regexes=ignore_regexes,
|
|
325
|
+
ignore_directories=ignore_directories,
|
|
326
|
+
case_sensitive=case_sensitive
|
|
327
|
+
)
|
|
328
|
+
event_handler.on_modified = on_modified
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
observer = Observer()
|
|
333
|
+
observer.schedule(event_handler, Config().get("working_dir"), recursive=True)
|
|
334
|
+
observer.start()
|
|
335
|
+
try:
|
|
336
|
+
while True:
|
|
337
|
+
time.sleep(1)
|
|
338
|
+
finally:
|
|
339
|
+
observer.stop()
|
|
340
|
+
observer.join()
|
|
341
|
+
|
|
342
|
+
asyncio.new_event_loop().run_until_complete(watch_loop())
|
|
343
|
+
return
|
|
289
344
|
asyncio.new_event_loop().run_until_complete(main())
|
|
290
345
|
|
|
291
346
|
|
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
import typing
|
|
6
6
|
import datetime
|
|
7
7
|
import getpass
|
|
8
|
+
import subprocess
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def rmdir(dir):
|
|
@@ -95,7 +96,9 @@ def replace_vars(string: str, vars: typing.Optional[typing.Dict[str, str]] = Non
|
|
|
95
96
|
old_string = string
|
|
96
97
|
for var, content in vars.items():
|
|
97
98
|
string = string.replace(f"$({var})", str(content))
|
|
98
|
-
|
|
99
|
+
if "$(ref)" in string:
|
|
100
|
+
ref = subprocess.check_output("git rev-parse --short HEAD", shell=True)
|
|
101
|
+
string = string.replace(f"$(ref)", str(ref))
|
|
99
102
|
return string
|
|
100
103
|
|
|
101
104
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.2.0"
|
|
2
2
|
MINIMAL_PIPENV = "2023.11.15"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: viur_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Command-line interface for ViUR application maintenance.
|
|
5
5
|
Home-page: https://github.com/viur-framework/viur-cli
|
|
6
6
|
Author: Andreas H. Kelch
|
|
@@ -17,6 +17,8 @@ Requires-Dist: click~=8.1.7
|
|
|
17
17
|
Requires-Dist: pipfile-requirements~=0.3
|
|
18
18
|
Requires-Dist: requests~=2.0
|
|
19
19
|
Requires-Dist: semver~=3.0
|
|
20
|
+
Requires-Dist: watchdog~=6.0
|
|
21
|
+
Dynamic: license-file
|
|
20
22
|
|
|
21
23
|
<div align="center">
|
|
22
24
|
<img src="https://github.com/viur-framework/viur-artwork/raw/main/icons/icon-cli.svg" height="196" alt="A hexagonal logo of the viur-cli" title="viur-cli">
|
|
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
|
|
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
|