daktari 0.0.223__py3-none-any.whl → 0.0.225__py3-none-any.whl

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.

Potentially problematic release.


This version of daktari might be problematic. Click here for more details.

daktari/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.223"
1
+ __version__ = "0.0.225"
daktari/checks/files.py CHANGED
@@ -2,7 +2,7 @@ from os.path import expanduser
2
2
  from typing import List
3
3
 
4
4
  from daktari.check import Check, CheckResult
5
- from daktari.file_utils import dir_exists, file_exists
5
+ from daktari.file_utils import dir_exists, file_exists, get_file_owner
6
6
  from daktari.os import OS
7
7
 
8
8
 
@@ -42,3 +42,24 @@ class DirExists(DirsExist):
42
42
  self.dir_paths = [dir_path]
43
43
  self.pass_fail_message = f"{dir_path} is <not/> present"
44
44
  self.suggestions = {OS.GENERIC: suggestion}
45
+
46
+
47
+ class FilesOwnedByUser(Check):
48
+ name = "files.ownedByUser"
49
+
50
+ def __init__(self, file_paths: List[str], expected_owner: str = "root", pass_fail_message: str = ""):
51
+ self.file_paths = file_paths
52
+ self.expected_owner = expected_owner
53
+ file_paths_str = ", ".join(file_paths)
54
+ self.pass_fail_message = pass_fail_message or f"{file_paths_str} are <not/> owned by {expected_owner}"
55
+
56
+ def check(self) -> CheckResult:
57
+ for file_path in self.file_paths:
58
+ expanded_file_path = expanduser(file_path)
59
+ if file_exists(expanded_file_path):
60
+ if get_file_owner(expanded_file_path) != self.expected_owner:
61
+ return self.verify(False, self.pass_fail_message)
62
+ else:
63
+ return self.failed(f"{expanded_file_path} is not present")
64
+
65
+ return self.verify(True, self.pass_fail_message)
@@ -1,6 +1,6 @@
1
1
  import json
2
2
  import logging
3
- import os.path
3
+ import os
4
4
  from json.decoder import JSONDecodeError
5
5
  from pathlib import Path
6
6
  from typing import Optional
@@ -186,6 +186,33 @@ class IntelliJNodePackageManagerConfigured(XmlFileXPathCheck):
186
186
  return current_package_manager.__contains__(self.package_manager_path)
187
187
 
188
188
 
189
+ class IntelliJTypescriptCompilerPathConfigured(XmlFileXPathCheck):
190
+ name = "intellij.typescriptCompilerPathConfigured"
191
+ file_path = ".idea/compiler.xml"
192
+ xpath_query = "./component[@name='TypeScriptCompiler']/option[@name='typeScriptServiceDirectory']"
193
+ depends_on = [IntelliJProjectImported]
194
+
195
+ def __init__(self, typescript_compiler_path: str):
196
+ self.typescript_compiler_path = typescript_compiler_path
197
+ resolved_path = typescript_compiler_path.replace("$PROJECT_DIR$", os.getcwd())
198
+ self.pass_fail_message = f"IntelliJ typescript compiler path has <not/> been set to {resolved_path}"
199
+
200
+ self.suggestions = {
201
+ OS.GENERIC: f"""
202
+ Follow the steps to set {resolved_path} as your typescript compiler path:
203
+ https://www.jetbrains.com/help/idea/typescript-support.html#ws_ts_use_ts_service_checkbox
204
+ """
205
+ }
206
+
207
+ def validate_query_result(self, result):
208
+ if result is None:
209
+ self.pass_fail_message = "IntelliJ typescript compiler path is <not/> set"
210
+ return False
211
+ current_typescript_compiler_path = result.get("value")
212
+ logging.debug(f"IntelliJ typescript compiler set to: {current_typescript_compiler_path}")
213
+ return current_typescript_compiler_path == self.typescript_compiler_path
214
+
215
+
189
216
  class IntelliJProjectSdkJavaVersion(XmlFileXPathCheck):
190
217
  name = "intellij.jdkVersionConfigured"
191
218
  file_path = ".idea/misc.xml"
@@ -3,7 +3,11 @@ import unittest
3
3
  from semver import VersionInfo
4
4
 
5
5
  from daktari.check import CheckStatus
6
- from daktari.checks.intellij_idea import IntelliJProjectSdkJavaVersion, get_intellij_version_from_product_info
6
+ from daktari.checks.intellij_idea import (
7
+ IntelliJProjectSdkJavaVersion,
8
+ get_intellij_version_from_product_info,
9
+ IntelliJTypescriptCompilerPathConfigured,
10
+ )
7
11
 
8
12
 
9
13
  class TestIntellijIdea(unittest.TestCase):
@@ -39,3 +43,24 @@ class TestIntellijIdea(unittest.TestCase):
39
43
  result = check.check()
40
44
  self.assertEqual(result.status, CheckStatus.PASS)
41
45
  self.assertEqual(result.summary, "IntelliJ Project SDK is set to Java 17: JDK_17")
46
+
47
+ def test_project_typescript_path_unset(self):
48
+ check = IntelliJTypescriptCompilerPathConfigured("$PROJECT_DIR$/node_modules/typescript")
49
+ check.file_path = "checks/test_resources/intellij_misc_no_ts_path.xml"
50
+ result = check.check()
51
+ self.assertEqual(result.status, CheckStatus.FAIL)
52
+ self.assertIn("IntelliJ typescript compiler path is not set", result.summary)
53
+
54
+ def test_project_typescript_path_set_wrong(self):
55
+ check = IntelliJTypescriptCompilerPathConfigured("/some/project/node_modules/typescript")
56
+ check.file_path = "checks/test_resources/intellij_misc_custom_ts_path.xml"
57
+ result = check.check()
58
+ self.assertEqual(result.status, CheckStatus.FAIL)
59
+ self.assertIn("IntelliJ typescript compiler path has not been set to", result.summary)
60
+
61
+ def test_project_typescript_path_set_correctly(self):
62
+ check = IntelliJTypescriptCompilerPathConfigured("$PROJECT_DIR$/node_modules/typescript")
63
+ check.file_path = "checks/test_resources/intellij_misc_custom_ts_path.xml"
64
+ result = check.check()
65
+ self.assertEqual(result.status, CheckStatus.PASS)
66
+ self.assertIn("IntelliJ typescript compiler path has been set to", result.summary)
daktari/file_utils.py CHANGED
@@ -4,6 +4,7 @@ from daktari.command_utils import get_stdout
4
4
 
5
5
  import os
6
6
  import re
7
+ from pwd import getpwuid
7
8
 
8
9
 
9
10
  def get_absolute_path(path: str) -> str:
@@ -44,3 +45,8 @@ def file_contains_text_regex(path: str, regex: str) -> bool:
44
45
  def dir_exists(path: str) -> bool:
45
46
  testing_dir = Path(path)
46
47
  return testing_dir.is_dir()
48
+
49
+
50
+ def get_file_owner(file_path: str) -> str:
51
+ file_stat = os.stat(file_path)
52
+ return getpwuid(file_stat.st_uid).pw_name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: daktari
3
- Version: 0.0.223
3
+ Version: 0.0.225
4
4
  Summary: Assist in setting up and maintaining developer environments
5
5
  Home-page: https://github.com/sonocent/daktari
6
6
  Author: Matt Russell
@@ -46,7 +46,7 @@ In the root of the project repository, create a `.daktari.py` configuration file
46
46
  ```python
47
47
  from daktari.checks.git import *
48
48
 
49
- version = "0.0.223"
49
+ version = "0.0.225"
50
50
  title = "My Project"
51
51
 
52
52
  checks = [
@@ -1,4 +1,4 @@
1
- daktari/__init__.py,sha256=_2K3f7YvALzroSUFZiSH1NYRIhHP-13hk1ikGLcgB8A,24
1
+ daktari/__init__.py,sha256=sfofVioZIs_eoUw13TxLA_I31csKkrTIG4gi0YxMANg,24
2
2
  daktari/__main__.py,sha256=iYwgtZZE2HD9Eh9Io6OliGQwCNZJSde_66jI6kF8xJU,1463
3
3
  daktari/asdf.py,sha256=fALVL6UTz1AYxuabw9MZeAES7J_CvImutUDD1Y2yWwM,509
4
4
  daktari/check.py,sha256=WzIiCrrdH7gCbElNwYbYkjhpmaOs_nUWfvkTBkfZlgs,4133
@@ -8,7 +8,7 @@ daktari/check_utils.py,sha256=rrmYWdekusXT4A2Tecbry_eV9DNt7bN9L5R0IJSPm5k,1027
8
8
  daktari/collection_utils.py,sha256=JOCcaSkXFPbj2ROszTS-FGv1s35HgHv0MCWgaHio4XE,165
9
9
  daktari/command_utils.py,sha256=3s3A3urin40eK40q9bzVnWGsSuU27FZbRkoDotlVKFk,2355
10
10
  daktari/config.py,sha256=75l_jhq7tcCIdl78RMcUlUu1fiG8cqKtwC3yV_H5FVE,6719
11
- daktari/file_utils.py,sha256=H0hFjXIkXicMz3yQrLauOjxH_pn0oa0L965_Ov-5ESw,1036
11
+ daktari/file_utils.py,sha256=C9neqCkF8QOQkOt9AGcynzaIvIKg0YKIoqb_mHjFwfQ,1187
12
12
  daktari/options.py,sha256=DTTCqn3BdfncWkkAFyag239fxgyxIo3IkM0R9bZhXgQ,1440
13
13
  daktari/os.py,sha256=usoya1LQThE68aXUfbgq67hJlHmtbEZtXpi7oRfnXXY,767
14
14
  daktari/resource_utils.py,sha256=LibGDZYOni6iVQq6OjF0cvFZrP5QmAmHoNKe4G_3BRc,331
@@ -31,11 +31,11 @@ daktari/checks/certs.py,sha256=_Q_1tNEwDoO-q-vPx2wOmGYqN-s4osK4gSRpKU5TFbU,1262
31
31
  daktari/checks/conan.py,sha256=_IWjb5wkbxh-dR6DnEaMpmgzIOkuLWnfMos8sRDmLek,4061
32
32
  daktari/checks/direnv.py,sha256=4J2GjbCX-2r7vxuRrNayGa2aq0WcNO07VFtgUvYU0Rc,2271
33
33
  daktari/checks/docker.py,sha256=8bmasFOvcCdVn95JHuI4uLqZoT43A06lNscFUfbEKjM,1560
34
- daktari/checks/files.py,sha256=XzaXvbXi5ZV7Krb4fLYkNCM0VQtDN9yo5tu0V9EAPtE,1331
34
+ daktari/checks/files.py,sha256=E9REDXly96K6e4rVXIDbpNiXlgYiQmiS3CdlloxlqNo,2239
35
35
  daktari/checks/flutter.py,sha256=1TI19pIiLVrAuJvoPMXzgX1yOVq6Q5K0TwHNSAUdR_g,1536
36
36
  daktari/checks/git.py,sha256=yII22HkvhjGM4bpr3wiLvPxi1pSBPiQcxdTyjqPXji4,6508
37
37
  daktari/checks/google.py,sha256=pVbMVWe_mcZ5v-Y6COMwjpMIRopSqzVvgwAQVA4x_Tc,4643
38
- daktari/checks/intellij_idea.py,sha256=QZr5w-E-dBOevGsYVPfMEsOpLc5Kw2KPP8SYKFRGNnw,8461
38
+ daktari/checks/intellij_idea.py,sha256=_8A3t5jIAzqyjkIAFjAFwKwYb4WdbPk4Ex02R6d7cFE,9792
39
39
  daktari/checks/java.py,sha256=vS4gfuLwLxuTLizvybRx2yYXnNLMTsSfmoYHp91rono,3542
40
40
  daktari/checks/kubernetes.py,sha256=BJjxAZzZ3y3t7oHBruUy8OxP41JaX0cxlLvTnFz-F8s,5886
41
41
  daktari/checks/misc.py,sha256=8-xvFvMCoZTaZIVCw5QWKtFT-wSkUSUXGBak02IB6yY,10489
@@ -45,7 +45,7 @@ daktari/checks/python.py,sha256=v6xuRwtFCjzTYMN3qRLu76Xm7Bn8NO7wVpI3d8dOBSc,658
45
45
  daktari/checks/ssh.py,sha256=NqFhO03u523yQaffCeemcRtnYowx6LDuufayzF1t5eQ,1285
46
46
  daktari/checks/terraform.py,sha256=fvA7VRRJftkISqcnEjbc9dUovfXEe0eXrQl2MvsnfSM,2476
47
47
  daktari/checks/test_certs.py,sha256=LmwjzNBEJauGSFYYLGevJ5H3FRkaO0piezUm3P-hrbM,1693
48
- daktari/checks/test_intellij_idea.py,sha256=SGohgXApjm1DzMC-r43FHJX04oimrIhijRmMjyinA_o,1905
48
+ daktari/checks/test_intellij_idea.py,sha256=dJ7Nu0eVyv1cpo8h5wUJ6w1rmsbGg3yxslaQKHT3So4,3207
49
49
  daktari/checks/test_java.py,sha256=f-JFGI-J-pBD1WgY8a88BO7XeJhvD87QSZK0kDnflls,3613
50
50
  daktari/checks/test_misc.py,sha256=tTvaPaZORjNf1dV8wPUKXDI3-JksyfdOsnZXFs7SLLE,587
51
51
  daktari/checks/test_onepassword.py,sha256=HLeNjkZd85ty1U4Ut3OSjWVa5msC1Fp1OF0IIWD69u4,1115
@@ -56,9 +56,9 @@ daktari/checks/yarn.py,sha256=T8b_oOoZ4l96delmPgPfgtaTkiUS129hoWlGIBcU7Io,5534
56
56
  daktari/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  daktari/resources/daktari-local-template.yaml,sha256=ik7KzMcG1r90nxDOk7t5G7P-BSxQIl2PocGUVe14c44,503
58
58
  daktari/resources/mock_cert.pem,sha256=AIc9dZOVIuxm7KFLunP5WSA1-LDWLOwpfu48B9xQ_Wg,82
59
- daktari-0.0.223.dist-info/LICENSE.txt,sha256=sMo18UdnQ7rY1SYg9gmop08ubzEQOGO1URYXu1Hxdx0,1051
60
- daktari-0.0.223.dist-info/METADATA,sha256=kKet-6oS6LemTwLgKDq1m8JbYN_ZSF-aW4sCu4A9nmA,3844
61
- daktari-0.0.223.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
62
- daktari-0.0.223.dist-info/entry_points.txt,sha256=Sqwxp-qsyRnWwGVHkd3hoeG7aPffCIRB4pouCD9BbYU,51
63
- daktari-0.0.223.dist-info/top_level.txt,sha256=LW6kawKAAyxUbGqpAbdedKRUyVy2DBzEZOalp0qDdF8,8
64
- daktari-0.0.223.dist-info/RECORD,,
59
+ daktari-0.0.225.dist-info/LICENSE.txt,sha256=sMo18UdnQ7rY1SYg9gmop08ubzEQOGO1URYXu1Hxdx0,1051
60
+ daktari-0.0.225.dist-info/METADATA,sha256=NVSuz0XGKFiEALzrqShwIsdIxXIE1DFRpQUfdnmckog,3844
61
+ daktari-0.0.225.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
62
+ daktari-0.0.225.dist-info/entry_points.txt,sha256=Sqwxp-qsyRnWwGVHkd3hoeG7aPffCIRB4pouCD9BbYU,51
63
+ daktari-0.0.225.dist-info/top_level.txt,sha256=LW6kawKAAyxUbGqpAbdedKRUyVy2DBzEZOalp0qDdF8,8
64
+ daktari-0.0.225.dist-info/RECORD,,