Skip to content

Commit 548dc06

Browse files
committed
Added find project root for --init
1 parent dc652d9 commit 548dc06

6 files changed

Lines changed: 22 additions & 16 deletions

File tree

remove-json-keys/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ license-files = [
1919
]
2020
dependencies = [
2121
"colorama>=0.4.6,<1.0.0 ; platform_system == 'Windows'",
22+
"find-project-root>=1.0.1,<2.0.0",
2223
"json5>=0.9.0,<1.0.0",
23-
"project-markers>=1.0.0,<2.0.0",
2424
"ucs-detect>=2.0.2,<3.0.0"
2525
]
2626
requires-python = ">=3.8,<4.0"

remove-json-keys/src/remove_json_keys/assets/data/package_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
},
2222
"commit_hashes": {
2323
"data": "ca32452",
24-
"locales": "2e62364"
24+
"locales": "dc652d9"
2525
}
2626
}

remove-json-keys/src/remove_json_keys/lib/init.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ def cli() -> sn:
1313
return cli
1414

1515
def config_file(cli: sn) -> None: # for --init
16-
import project_markers
17-
target_path = Path.cwd() / f'.{cli.short_name}.config.json5'
18-
in_project_root = None
19-
if not any((Path.cwd() / marker).exists() for marker in project_markers): # type: ignore
20-
log.warn(f'{cli.msgs.warn_NO_PROJECT_ROOT_FOUND_IN} {Path.cwd()}')
16+
import find_project_root
17+
project_root = find_project_root(max_depth=20) # type: ignore
18+
if project_root:
19+
target_path = Path(project_root) / f'.{cli.short_name}.config.json5'
20+
in_project_root = True
21+
else:
22+
log.warn(cli.msgs.NO_PROJECT_ROOT_FOUND)
2123
user_resp = input(f'{cli.msgs.prompt_INIT_CONFIG_HERE_ANYWAY}? (y/N): ').strip().lower()
2224
if not user_resp.startswith('y') : return
23-
else : in_project_root = True # for move tip
25+
target_path = Path.cwd() / f'.{cli.short_name}.config.json5'
26+
in_project_root = False
2427

2528
# Handle existing file
2629
if target_path.exists():

translate-messages/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ license-files = [
1919
]
2020
dependencies = [
2121
"colorama>=0.4.6,<1.0.0 ; platform_system == 'Windows'",
22+
"find-project-root>=1.0.1,<2.0.0",
2223
"json5>=0.9.0,<1.0.0",
23-
"project-markers>=1.0.0,<2.0.0",
2424
"translate>=3.8.0,<4.0.0",
2525
"ucs-detect>=2.0.2,<3.0.0"
2626
]

translate-messages/src/translate_messages/assets/data/package_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
],
3030
"commit_hashes": {
3131
"data": "ca32452",
32-
"locales": "2e62364"
32+
"locales": "dc652d9"
3333
}
3434
}

translate-messages/src/translate_messages/lib/init.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ def cli() -> sn:
1414
return cli
1515

1616
def config_file(cli: sn) -> None: # for --init
17-
import project_markers
18-
target_path = Path.cwd() / f'.{cli.short_name}.config.json5'
19-
in_project_root = None
20-
if not any((Path.cwd() / marker).exists() for marker in project_markers): # type: ignore
21-
log.warn(f'{cli.msgs.warn_NO_PROJECT_ROOT_FOUND_IN} {Path.cwd()}')
17+
import find_project_root
18+
project_root = find_project_root(max_depth=20) # type: ignore
19+
if project_root:
20+
target_path = Path(project_root) / f'.{cli.short_name}.config.json5'
21+
in_project_root = True
22+
else:
23+
log.warn(cli.msgs.NO_PROJECT_ROOT_FOUND)
2224
user_resp = input(f'{cli.msgs.prompt_INIT_CONFIG_HERE_ANYWAY}? (y/N): ').strip().lower()
2325
if not user_resp.startswith('y') : return
24-
else : in_project_root = True # for move tip
26+
target_path = Path.cwd() / f'.{cli.short_name}.config.json5'
27+
in_project_root = False
2528

2629
# Handle existing file
2730
if target_path.exists():

0 commit comments

Comments
 (0)