daktari 0.0.303__py3-none-any.whl → 0.0.306__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.
daktari/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.303"
1
+ __version__ = "0.0.306"
daktari/checks/npmrc.py CHANGED
@@ -9,12 +9,14 @@ from daktari.command_utils import can_run_command
9
9
  from daktari.file_utils import file_exists
10
10
  from daktari.os import OS
11
11
 
12
+ PLACEHOLDER_TOKEN = "UPDATE_WITH_TOKEN"
13
+
12
14
 
13
15
  @dataclass
14
16
  class NpmrcScope:
15
17
  name: str
16
18
  registry: str
17
- requireAuthToken: bool = False
19
+ require_auth_token: bool = False
18
20
 
19
21
 
20
22
  def get_npmrc_path() -> str:
@@ -42,8 +44,7 @@ def get_registry_host(registry_url: str) -> str:
42
44
  def npmrc_contains_scope_registry(lines: List[str], scope: NpmrcScope) -> bool:
43
45
  expected_line = f"@{scope.name}:registry={scope.registry}"
44
46
  for line in lines:
45
- stripped = line.strip()
46
- if stripped == expected_line or stripped.startswith(expected_line + "\n"):
47
+ if line.strip() == expected_line:
47
48
  return True
48
49
  return False
49
50
 
@@ -55,7 +56,7 @@ def npmrc_contains_auth_token(lines: List[str], registry_url: str) -> bool:
55
56
  stripped = line.strip()
56
57
  if stripped.startswith(auth_token_prefix):
57
58
  token_value = stripped[len(auth_token_prefix) :]
58
- if token_value and token_value != "UPDATE_WITH_TOKEN":
59
+ if token_value and token_value != PLACEHOLDER_TOKEN:
59
60
  return True
60
61
  return False
61
62
 
@@ -63,41 +64,30 @@ def npmrc_contains_auth_token(lines: List[str], registry_url: str) -> bool:
63
64
  def npmrc_scope_is_configured(lines: List[str], scope: NpmrcScope) -> bool:
64
65
  if not npmrc_contains_scope_registry(lines, scope):
65
66
  return False
66
- if scope.requireAuthToken and not npmrc_contains_auth_token(lines, scope.registry):
67
+ if scope.require_auth_token and not npmrc_contains_auth_token(lines, scope.registry):
67
68
  return False
68
69
  return True
69
70
 
70
71
 
71
72
  def get_npmrc_suggestion(scope: NpmrcScope) -> str:
72
73
  lines = [f"@{scope.name}:registry={scope.registry}"]
73
- if scope.requireAuthToken:
74
+ if scope.require_auth_token:
74
75
  host = get_registry_host(scope.registry)
75
- lines.append(f"//{host}/:_authToken=UPDATE_WITH_TOKEN")
76
+ lines.append(f"//{host}/:_authToken={PLACEHOLDER_TOKEN}")
76
77
  return "\n".join(lines)
77
78
 
78
79
 
79
- def get_npmrc_token_for_registry(registry_url: str) -> Optional[str]:
80
- lines = get_npmrc_contents()
81
- host = get_registry_host(registry_url)
82
- auth_token_prefix = f"//{host}/:_authToken="
83
- for line in lines:
84
- stripped = line.strip()
85
- if stripped.startswith(auth_token_prefix):
86
- return stripped[len(auth_token_prefix) :]
87
- return None
88
-
89
-
90
80
  class NpmrcScopeConfigured(Check):
91
81
  name = "npmrc.scopeConfigured"
92
82
 
93
- def __init__(self, scope: NpmrcScope, tokenInstructions: Optional[str] = None):
83
+ def __init__(self, scope: NpmrcScope, token_instructions: Optional[str] = None):
94
84
  self.scope = scope
95
85
  self.npmrc_suggestion = get_npmrc_suggestion(scope)
96
- tokenInstructionString = f"\n\n{tokenInstructions}" if tokenInstructions else ""
86
+ token_instruction_string = f"\n\n{token_instructions}" if token_instructions else ""
97
87
  self.suggestions = {
98
88
  OS.GENERIC: f"""Add the lines below to ~/.npmrc:
99
89
 
100
- {self.npmrc_suggestion}{tokenInstructionString}"""
90
+ {self.npmrc_suggestion}{token_instruction_string}"""
101
91
  }
102
92
 
103
93
  def check(self) -> CheckResult:
@@ -72,14 +72,14 @@ class TestNpmrcHelpers(unittest.TestCase):
72
72
  self.assertFalse(npmrc_contains_auth_token(lines, TEST_REGISTRY))
73
73
 
74
74
  def test_npmrc_scope_is_configured_without_auth(self):
75
- scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, requireAuthToken=False)
75
+ scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, require_auth_token=False)
76
76
  lines = [
77
77
  f"@{TEST_SCOPE_NAME}:registry={TEST_REGISTRY}\n",
78
78
  ]
79
79
  self.assertTrue(npmrc_scope_is_configured(lines, scope))
80
80
 
81
81
  def test_npmrc_scope_is_configured_with_auth_present(self):
82
- scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, requireAuthToken=True)
82
+ scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, require_auth_token=True)
83
83
  lines = [
84
84
  f"@{TEST_SCOPE_NAME}:registry={TEST_REGISTRY}\n",
85
85
  f"//{TEST_REGISTRY_HOST}/:_authToken={TEST_AUTH_TOKEN}\n",
@@ -87,7 +87,7 @@ class TestNpmrcHelpers(unittest.TestCase):
87
87
  self.assertTrue(npmrc_scope_is_configured(lines, scope))
88
88
 
89
89
  def test_npmrc_scope_is_configured_with_auth_missing(self):
90
- scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, requireAuthToken=True)
90
+ scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, require_auth_token=True)
91
91
  lines = [
92
92
  f"@{TEST_SCOPE_NAME}:registry={TEST_REGISTRY}\n",
93
93
  ]
@@ -101,12 +101,12 @@ class TestNpmrcHelpers(unittest.TestCase):
101
101
  self.assertFalse(npmrc_scope_is_configured(lines, scope))
102
102
 
103
103
  def test_get_npmrc_suggestion_without_auth(self):
104
- scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, requireAuthToken=False)
104
+ scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, require_auth_token=False)
105
105
  suggestion = get_npmrc_suggestion(scope)
106
106
  self.assertEqual(suggestion, f"@{TEST_SCOPE_NAME}:registry={TEST_REGISTRY}")
107
107
 
108
108
  def test_get_npmrc_suggestion_with_auth(self):
109
- scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, requireAuthToken=True)
109
+ scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, require_auth_token=True)
110
110
  suggestion = get_npmrc_suggestion(scope)
111
111
  expected = f"@{TEST_SCOPE_NAME}:registry={TEST_REGISTRY}\n//{TEST_REGISTRY_HOST}/:_authToken=UPDATE_WITH_TOKEN"
112
112
  self.assertEqual(suggestion, expected)
@@ -119,7 +119,7 @@ class TestNpmrcScopeConfigured(unittest.TestCase):
119
119
  f"@{TEST_SCOPE_NAME}:registry={TEST_REGISTRY}\n",
120
120
  f"//{TEST_REGISTRY_HOST}/:_authToken={TEST_AUTH_TOKEN}\n",
121
121
  ]
122
- scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, requireAuthToken=True)
122
+ scope = NpmrcScope(name=TEST_SCOPE_NAME, registry=TEST_REGISTRY, require_auth_token=True)
123
123
  result = NpmrcScopeConfigured(scope).check()
124
124
  self.assertEqual(result.status, CheckStatus.PASS)
125
125
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: daktari
3
- Version: 0.0.303
3
+ Version: 0.0.306
4
4
  Summary: Assist in setting up and maintaining developer environments
5
5
  Author-email: Matt Russell <matthew.russell@sonocent.com>
6
6
  License: Copyright 2021 Sonocent Ltd
@@ -18,8 +18,8 @@ Requires-Dist: ansicolors==1.1.8
18
18
  Requires-Dist: distro==1.9.0
19
19
  Requires-Dist: pyfiglet==1.0.4
20
20
  Requires-Dist: importlib_resources==6.5.2
21
- Requires-Dist: packaging==25.0
22
- Requires-Dist: setuptools==80.9.0
21
+ Requires-Dist: packaging==26.0
22
+ Requires-Dist: setuptools==80.10.2
23
23
  Requires-Dist: requests==2.32.5
24
24
  Requires-Dist: responses==0.25.8
25
25
  Requires-Dist: semver==3.0.4
@@ -45,7 +45,7 @@ In the root of the project repository, create a `.daktari.py` configuration file
45
45
  ```python
46
46
  from daktari.checks.git import *
47
47
 
48
- version = "0.0.303"
48
+ version = "0.0.306"
49
49
  title = "My Project"
50
50
 
51
51
  checks = [
@@ -1,4 +1,4 @@
1
- daktari/__init__.py,sha256=BDs1YTavXW5cEXxV1GC0G1gQi5n9pQ6qqvxpiQRcIqE,24
1
+ daktari/__init__.py,sha256=7r1HzA9y9fwDMK01WA-_tQZsgGPDISub7vpgL7iq1KY,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
@@ -41,7 +41,7 @@ daktari/checks/java.py,sha256=vS4gfuLwLxuTLizvybRx2yYXnNLMTsSfmoYHp91rono,3542
41
41
  daktari/checks/kubernetes.py,sha256=BJjxAZzZ3y3t7oHBruUy8OxP41JaX0cxlLvTnFz-F8s,5886
42
42
  daktari/checks/misc.py,sha256=O9_cCkcbigMF7uoqUebDT7mMmmKzQ8EwmIQRBY6vZcc,10855
43
43
  daktari/checks/nodejs.py,sha256=KOCLNQqZqaCalxcIajoDQDom1Zi4_noV4mV_-YZv_4E,2873
44
- daktari/checks/npmrc.py,sha256=z-hyy4Zevv8q9AE8f5ua54PoSASMk7HLF39Hf2nDWvU,4546
44
+ daktari/checks/npmrc.py,sha256=aqx08CIpYybEiMJogjJ9vto1G1ne_eBR8bh-yVrFgqs,4154
45
45
  daktari/checks/onepassword.py,sha256=C2HWNlypBDTUx4K4IrrEVIkMqivKzX97oE0rENP1xK4,4155
46
46
  daktari/checks/pnpm.py,sha256=alEmcc1F-T998ECZ7p7JJ4DaaznnzLwLFz--7mV33Dk,339
47
47
  daktari/checks/python.py,sha256=v6xuRwtFCjzTYMN3qRLu76Xm7Bn8NO7wVpI3d8dOBSc,658
@@ -51,7 +51,7 @@ daktari/checks/test_certs.py,sha256=LmwjzNBEJauGSFYYLGevJ5H3FRkaO0piezUm3P-hrbM,
51
51
  daktari/checks/test_intellij_idea.py,sha256=dJ7Nu0eVyv1cpo8h5wUJ6w1rmsbGg3yxslaQKHT3So4,3207
52
52
  daktari/checks/test_java.py,sha256=f-JFGI-J-pBD1WgY8a88BO7XeJhvD87QSZK0kDnflls,3613
53
53
  daktari/checks/test_misc.py,sha256=tTvaPaZORjNf1dV8wPUKXDI3-JksyfdOsnZXFs7SLLE,587
54
- daktari/checks/test_npmrc.py,sha256=mJG_kO5a7bqWx0NaBRrV6X_4_GKB5-6vU_6uKZQHAmU,7168
54
+ daktari/checks/test_npmrc.py,sha256=Bv_Amx2S7-2frBtHObJqBaRryEPqCrl4O7I_z4h44zM,7180
55
55
  daktari/checks/test_onepassword.py,sha256=HLeNjkZd85ty1U4Ut3OSjWVa5msC1Fp1OF0IIWD69u4,1115
56
56
  daktari/checks/test_pnpm.py,sha256=mZJgQ149V91YtxU4nENtalyyHZBawg4lbtxcW3IoWI0,925
57
57
  daktari/checks/test_ssh.py,sha256=XJECzM9BNODSxfkK71P9TyavlBagzgkCfKWdhlOD7zU,930
@@ -61,9 +61,9 @@ daktari/checks/yarn.py,sha256=T8b_oOoZ4l96delmPgPfgtaTkiUS129hoWlGIBcU7Io,5534
61
61
  daktari/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  daktari/resources/daktari-local-template.yaml,sha256=ik7KzMcG1r90nxDOk7t5G7P-BSxQIl2PocGUVe14c44,503
63
63
  daktari/resources/mock_cert.pem,sha256=AIc9dZOVIuxm7KFLunP5WSA1-LDWLOwpfu48B9xQ_Wg,82
64
- daktari-0.0.303.dist-info/licenses/LICENSE.txt,sha256=sMo18UdnQ7rY1SYg9gmop08ubzEQOGO1URYXu1Hxdx0,1051
65
- daktari-0.0.303.dist-info/METADATA,sha256=CRag-PvQZ0oOqNhrYvrf8RSMV4XzhV4uoq6joGqjkR0,4557
66
- daktari-0.0.303.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
67
- daktari-0.0.303.dist-info/entry_points.txt,sha256=mfQXkwKyloAzf7sv78icBo1PtRwf9hCP_816F6REf-I,50
68
- daktari-0.0.303.dist-info/top_level.txt,sha256=LW6kawKAAyxUbGqpAbdedKRUyVy2DBzEZOalp0qDdF8,8
69
- daktari-0.0.303.dist-info/RECORD,,
64
+ daktari-0.0.306.dist-info/licenses/LICENSE.txt,sha256=sMo18UdnQ7rY1SYg9gmop08ubzEQOGO1URYXu1Hxdx0,1051
65
+ daktari-0.0.306.dist-info/METADATA,sha256=fb4UJQ1uM-cGjNaxWKNP01kTteyo5yz02m3ID84dNU8,4558
66
+ daktari-0.0.306.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
67
+ daktari-0.0.306.dist-info/entry_points.txt,sha256=mfQXkwKyloAzf7sv78icBo1PtRwf9hCP_816F6REf-I,50
68
+ daktari-0.0.306.dist-info/top_level.txt,sha256=LW6kawKAAyxUbGqpAbdedKRUyVy2DBzEZOalp0qDdF8,8
69
+ daktari-0.0.306.dist-info/RECORD,,