viur-cli 2.3.0__tar.gz → 2.3.1__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 (28) hide show
  1. {viur_cli-2.3.0/src/viur_cli.egg-info → viur_cli-2.3.1}/PKG-INFO +1 -1
  2. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/conf.py +48 -34
  3. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/version.py +1 -1
  4. {viur_cli-2.3.0 → viur_cli-2.3.1/src/viur_cli.egg-info}/PKG-INFO +1 -1
  5. {viur_cli-2.3.0 → viur_cli-2.3.1}/LICENSE +0 -0
  6. {viur_cli-2.3.0 → viur_cli-2.3.1}/README.md +0 -0
  7. {viur_cli-2.3.0 → viur_cli-2.3.1}/pyproject.toml +0 -0
  8. {viur_cli-2.3.0 → viur_cli-2.3.1}/setup.cfg +0 -0
  9. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/__init__.py +0 -0
  10. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/build.py +0 -0
  11. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/cli.py +0 -0
  12. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/cloud.py +0 -0
  13. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/deprecated.py +0 -0
  14. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/local.py +0 -0
  15. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/package.py +0 -0
  16. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/scriptor/__init__.py +0 -0
  17. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/scriptor/cli.py +0 -0
  18. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/scripts/__init__.py +0 -0
  19. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/scripts/get_pyodide.py +0 -0
  20. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/setup.py +0 -0
  21. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/tool.py +0 -0
  22. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/update.py +0 -0
  23. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli/utils.py +0 -0
  24. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli.egg-info/SOURCES.txt +0 -0
  25. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli.egg-info/dependency_links.txt +0 -0
  26. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli.egg-info/entry_points.txt +0 -0
  27. {viur_cli-2.3.0 → viur_cli-2.3.1}/src/viur_cli.egg-info/requires.txt +0 -0
  28. {viur_cli-2.3.0 → viur_cli-2.3.1}/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.0
3
+ Version: 2.3.1
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
@@ -2,82 +2,96 @@ import json
2
2
  import click
3
3
  import requests
4
4
  import difflib
5
+ import os
5
6
  from .utils import *
6
7
  from .version import __version__ as cli_version
7
8
 
8
9
 
9
10
  class Config(dict):
10
- CONFIG_FILE = None
11
- PROJECT_CONFIG_VERSION = None
12
- LAST_VERSION = None
11
+ """
12
+ Abstraction layer for managing config files.
13
+ """
13
14
 
14
- def __init__(self, *args, **kwargs):
15
- self.load()
15
+ FILENAME = None
16
+ """
17
+ The filename used for this configuration file.
18
+ """
16
19
 
17
- def load(self):
18
- """
19
- Load project.json and write to the global projectConfig.
20
+ VERSION = None
21
+ """
22
+ The current version for this configuration file, which is tied to the viur-cli package.
23
+ """
20
24
 
21
- This function is responsible for loading the project.json configuration file and populating the global
22
- projectConfig variable.
23
- It handles error checks, such as missing or invalid JSON configuration files, and updates the project
24
- configuration.
25
+ def __init__(self, *, path=None):
26
+ self.path = path
25
27
 
26
- :param path: str, optional
27
- The path to the project.json file. If not provided, the default projectConfigFilePath is used.
28
+ if self.VERSION:
29
+ self["format"] = self.VERSION
28
30
 
29
- :return: dict
30
- The project configuration loaded from the project.json file.
31
+ self.load()
32
+
33
+ def load(self):
34
+ """
35
+ Load configuration from a file into this config object.
31
36
  """
32
37
  # Search in any parent folder for a project.json,
33
38
  # change working directory because subsequent commands
34
39
  # require for project root folder.
35
40
 
36
41
  changed = False
37
- while not os.path.exists(self.CONFIG_FILE):
42
+ while not os.path.exists(self.FILENAME):
38
43
  os.chdir("..")
39
44
  changed = True
40
45
 
41
46
  if os.getcwd() == "/":
42
- echo_fatal(f"{self.CONFIG_FILE} not found - please check if you are in the right folder.")
47
+
48
+ if self.path:
49
+ self.save()
50
+ self.load()
51
+ return
52
+ else:
53
+ echo_fatal(f"{self.FILENAME} not found - please check if you are in the right folder.")
43
54
 
44
55
  if changed:
45
56
  echo_info(f"Project root is {os.getcwd()}")
46
57
 
47
58
  try:
48
- f = open(self.CONFIG_FILE, "r")
59
+ f = open(self.FILENAME, "r")
60
+ self.path = os.getcwd()
49
61
  self.update(json.loads(f.read()))
50
62
 
51
63
 
52
64
  except FileNotFoundError:
53
- echo_fatal(f"Can't open {self.CONFIG_FILE} for reading")
65
+ echo_fatal(f"Can't open {self.FILENAME} for reading")
54
66
 
55
67
  except json.decoder.JSONDecodeError as e:
56
68
  echo_fatal(
57
- f"The configuration in {self.CONFIG_FILE} contains invalid JSON: {str(e)}. Please verify right syntax.")
69
+ f"The configuration in {self.FILENAME} contains invalid JSON: {str(e)}. Please verify right syntax.")
70
+
58
71
  self.migrate()
59
72
 
60
73
  def migrate(self):
74
+ """
75
+ A hook for migrating a read config.
76
+ """
61
77
  pass
62
78
 
63
79
  def save(self):
64
80
  """
65
- Write the current projectConfig dictionary to project.json.
81
+ Write the current configuration back to the file.
66
82
  """
67
- with open(self.CONFIG_FILE, "w") as f:
83
+ os.chdir(self.path)
84
+ with open(self.FILENAME, "w") as f:
68
85
  json.dump(self, f, indent=4, sort_keys=True)
69
86
  f.write('\n')
70
87
 
71
88
 
72
89
  class ProjectConfig(Config):
73
- CONFIG_FILE = "project.json"
74
- PROJECT_CONFIG_VERSION = "2.0.0"
75
- LAST_VERSION = ""
90
+ FILENAME = "project.json"
91
+ VERSION = "2.0.0"
76
92
 
77
93
  def __init__(self):
78
-
79
94
  self["default"] = {}
80
- self["format"] = self.PROJECT_CONFIG_VERSION
81
95
  super().__init__()
82
96
 
83
97
  def get_profile(self, profile):
@@ -129,7 +143,7 @@ class ProjectConfig(Config):
129
143
  self["format"] = old_format
130
144
  del self["default"]["format"]
131
145
 
132
- assert self["format"] in ["1.0.0", "1.0.1", "1.1.0", "1.1.1", "1.2.0", self.PROJECT_CONFIG_VERSION], \
146
+ assert self["format"] in ["1.0.0", "1.0.1", "1.1.0", "1.1.1", "1.2.0", self.VERSION], \
133
147
  "Invalid formatversion, you have to fix it manually"
134
148
 
135
149
  # Version 1.0.1
@@ -229,18 +243,18 @@ class ScriptorConfig(Config):
229
243
  Manage scriptor configuration.
230
244
  TODO miragte with other config
231
245
  """
232
- CONFIG_FILE = "viur_scriptor_config.json"
246
+ FILENAME = "viur_scriptor_config.json"
233
247
  DEFAULT_BASE_URL = "http://localhost:8080"
234
248
  DEFAULT_WORKING_DIR = "scripts/"
235
- _instance = None
236
249
 
237
- def __init__(self, *args, **kwargs):
250
+ def __init__(self, **kwargs):
238
251
  self.update({
239
252
  "base_url": self.DEFAULT_BASE_URL,
240
253
  "working_dir": self.DEFAULT_WORKING_DIR,
241
254
  })
242
- super().__init__(*args, **kwargs)
255
+ super().__init__(**kwargs)
243
256
 
244
257
 
258
+ # Create specific configs
245
259
  config = ProjectConfig()
246
- scriptor_config = ScriptorConfig()
260
+ scriptor_config = ScriptorConfig(path=config.path)
@@ -1,2 +1,2 @@
1
- __version__ = "2.3.0"
1
+ __version__ = "2.3.1"
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.0
3
+ Version: 2.3.1
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