dotctl 1.0.3__tar.gz → 1.0.4__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.
- {dotctl-1.0.3/src/dotctl.egg-info → dotctl-1.0.4}/PKG-INFO +1 -1
- {dotctl-1.0.3 → dotctl-1.0.4}/pyproject.toml +1 -1
- dotctl-1.0.4/src/dotctl/actions/creator.py +89 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/initializer.py +35 -3
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/arg_manager.py +16 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/handlers/git_handler.py +10 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/main.py +3 -1
- dotctl-1.0.4/src/dotctl/templates/dev.yaml +12 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/templates/kde.yaml +0 -4
- {dotctl-1.0.3 → dotctl-1.0.4/src/dotctl.egg-info}/PKG-INFO +1 -1
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl.egg-info/SOURCES.txt +1 -2
- dotctl-1.0.4/src/dotctl.egg-info/top_level.txt +1 -0
- dotctl-1.0.3/src/dotctl/actions/creator.py +0 -47
- dotctl-1.0.3/src/dotctl/templates/dev.yaml +0 -22
- dotctl-1.0.3/src/dotctl.egg-info/top_level.txt +0 -2
- dotctl-1.0.3/src/plasmasaver/__init__.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/LICENSE +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/README.md +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/setup.cfg +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/__init__.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/__init__.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/activator.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/exporter.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/importer.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/lister.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/remover.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/saver.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/switcher.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/actions/wiper.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/exception.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/handlers/__init__.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/handlers/config_handler.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/handlers/data_handler.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/handlers/hooks_handler.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/hooks/post_apply.sh +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/hooks/pre_apply.sh +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/paths.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/templates/__init__.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/templates/other.yaml +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/utils.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl/validators.py +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl.egg-info/dependency_links.txt +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl.egg-info/entry_points.txt +0 -0
- {dotctl-1.0.3 → dotctl-1.0.4}/src/dotctl.egg-info/requires.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dotctl
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments.
|
|
5
5
|
Author-email: Pankaj Jackson <pankajackson@live.co.uk>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dotctl"
|
|
7
|
-
version = "v1.0.
|
|
7
|
+
version = "v1.0.4"
|
|
8
8
|
description = "A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
import socket
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from git import Repo, GitCommandError, InvalidGitRepositoryError
|
|
7
|
+
from dotctl.paths import app_profile_directory
|
|
8
|
+
from dotctl.utils import log
|
|
9
|
+
from dotctl.exception import exception_handler
|
|
10
|
+
from dotctl.handlers.hooks_handler import hooks_initializer
|
|
11
|
+
from dotctl.handlers.config_handler import conf_initializer
|
|
12
|
+
from dotctl.handlers.git_handler import (
|
|
13
|
+
add_changes,
|
|
14
|
+
commit_changes,
|
|
15
|
+
get_repo,
|
|
16
|
+
get_repo_branches,
|
|
17
|
+
git_fetch,
|
|
18
|
+
create_branch,
|
|
19
|
+
create_empty_branch,
|
|
20
|
+
is_remote_repo,
|
|
21
|
+
is_repo_changed,
|
|
22
|
+
push_existing_branch,
|
|
23
|
+
push_new_branch,
|
|
24
|
+
)
|
|
25
|
+
from dotctl import __APP_NAME__, __DEFAULT_PROFILE__
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class CreatorProps:
|
|
30
|
+
profile: str
|
|
31
|
+
profile_dir: Path
|
|
32
|
+
fetch: bool
|
|
33
|
+
config: str | Path | None
|
|
34
|
+
env: str | None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
creator_default_props = CreatorProps(
|
|
38
|
+
profile=__DEFAULT_PROFILE__,
|
|
39
|
+
profile_dir=Path(app_profile_directory),
|
|
40
|
+
fetch=False,
|
|
41
|
+
config=None,
|
|
42
|
+
env=None,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@exception_handler
|
|
47
|
+
def create(props: CreatorProps):
|
|
48
|
+
log("Creating profile...")
|
|
49
|
+
repo = get_repo(props.profile_dir)
|
|
50
|
+
|
|
51
|
+
if props.fetch:
|
|
52
|
+
git_fetch(repo)
|
|
53
|
+
|
|
54
|
+
_, _, _, all_profiles = get_repo_branches(repo)
|
|
55
|
+
if props.profile in all_profiles:
|
|
56
|
+
log(f"Profile '{props.profile}' already exists.")
|
|
57
|
+
return
|
|
58
|
+
if props.env or props.config:
|
|
59
|
+
if props.config is not None and isinstance(props.config, str):
|
|
60
|
+
props.config = Path(props.config)
|
|
61
|
+
create_empty_branch(repo, props.profile)
|
|
62
|
+
conf_initializer(
|
|
63
|
+
env=props.env,
|
|
64
|
+
custom_config=props.config,
|
|
65
|
+
)
|
|
66
|
+
hooks_initializer()
|
|
67
|
+
else:
|
|
68
|
+
create_branch(repo, props.profile)
|
|
69
|
+
|
|
70
|
+
add_changes(repo=repo)
|
|
71
|
+
if is_repo_changed(repo=repo):
|
|
72
|
+
hostname = socket.gethostname()
|
|
73
|
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
74
|
+
full_message = f"{hostname} | Profile Initialized | {timestamp}"
|
|
75
|
+
commit_changes(repo=repo, message=full_message)
|
|
76
|
+
is_remote, _ = is_remote_repo(repo=repo)
|
|
77
|
+
_, remote_profiles, active_profile, all_profiles = get_repo_branches(repo)
|
|
78
|
+
if is_remote:
|
|
79
|
+
if props.profile not in remote_profiles:
|
|
80
|
+
git_fetch(repo=repo)
|
|
81
|
+
_, remote_profiles, active_profile, all_profiles = get_repo_branches(
|
|
82
|
+
repo
|
|
83
|
+
)
|
|
84
|
+
if not props.profile in remote_profiles:
|
|
85
|
+
push_new_branch(repo=repo)
|
|
86
|
+
else:
|
|
87
|
+
push_existing_branch(repo=repo)
|
|
88
|
+
|
|
89
|
+
log(f"Profile '{props.profile}' created and activated successfully.")
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
from datetime import datetime
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
from dataclasses import dataclass
|
|
4
|
+
import socket
|
|
3
5
|
from dotctl.paths import app_profile_directory
|
|
4
6
|
from dotctl.utils import log
|
|
5
7
|
from dotctl.handlers.config_handler import conf_initializer
|
|
6
8
|
from dotctl.handlers.hooks_handler import hooks_initializer
|
|
7
9
|
from dotctl.handlers.git_handler import (
|
|
10
|
+
add_changes,
|
|
11
|
+
commit_changes,
|
|
12
|
+
get_repo_branches,
|
|
13
|
+
git_fetch,
|
|
8
14
|
is_git_repo,
|
|
9
15
|
clone_repo,
|
|
10
16
|
create_local_repo,
|
|
11
17
|
checkout_branch,
|
|
18
|
+
is_remote_repo,
|
|
19
|
+
is_repo_changed,
|
|
20
|
+
push_existing_branch,
|
|
21
|
+
push_new_branch,
|
|
12
22
|
)
|
|
13
23
|
from dotctl.exception import exception_handler
|
|
14
24
|
from dotctl import __DEFAULT_PROFILE__
|
|
@@ -16,7 +26,7 @@ from dotctl import __DEFAULT_PROFILE__
|
|
|
16
26
|
|
|
17
27
|
@dataclass
|
|
18
28
|
class InitializerProps:
|
|
19
|
-
|
|
29
|
+
config: str | Path | None
|
|
20
30
|
git_url: str | None
|
|
21
31
|
profile: str | None
|
|
22
32
|
env: str | None
|
|
@@ -24,7 +34,7 @@ class InitializerProps:
|
|
|
24
34
|
|
|
25
35
|
|
|
26
36
|
initializer_default_props = InitializerProps(
|
|
27
|
-
|
|
37
|
+
config=None,
|
|
28
38
|
git_url=None,
|
|
29
39
|
profile=None,
|
|
30
40
|
env=None,
|
|
@@ -57,9 +67,31 @@ def initialise(props: InitializerProps):
|
|
|
57
67
|
if props.profile:
|
|
58
68
|
checkout_branch(repo, props.profile)
|
|
59
69
|
|
|
70
|
+
if props.config is not None and isinstance(props.config, str):
|
|
71
|
+
props.config = Path(props.config)
|
|
72
|
+
|
|
60
73
|
conf_initializer(
|
|
61
74
|
env=props.env,
|
|
62
|
-
custom_config=props.
|
|
75
|
+
custom_config=props.config,
|
|
63
76
|
)
|
|
64
77
|
hooks_initializer()
|
|
78
|
+
add_changes(repo=repo)
|
|
79
|
+
if is_repo_changed(repo=repo):
|
|
80
|
+
hostname = socket.gethostname()
|
|
81
|
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
82
|
+
full_message = f"{hostname} | Profile Initialized | {timestamp}"
|
|
83
|
+
commit_changes(repo=repo, message=full_message)
|
|
84
|
+
is_remote, _ = is_remote_repo(repo=repo)
|
|
85
|
+
_, remote_profiles, active_profile, all_profiles = get_repo_branches(repo)
|
|
86
|
+
if is_remote:
|
|
87
|
+
if props.profile not in remote_profiles:
|
|
88
|
+
git_fetch(repo=repo)
|
|
89
|
+
_, remote_profiles, active_profile, all_profiles = get_repo_branches(
|
|
90
|
+
repo
|
|
91
|
+
)
|
|
92
|
+
if not props.profile in remote_profiles:
|
|
93
|
+
push_new_branch(repo=repo)
|
|
94
|
+
else:
|
|
95
|
+
push_existing_branch(repo=repo)
|
|
96
|
+
|
|
65
97
|
log("Profile initialized successfully.")
|
|
@@ -129,6 +129,22 @@ def get_parser() -> argparse.ArgumentParser:
|
|
|
129
129
|
action="store_true",
|
|
130
130
|
help="Fetch and Sync profile information from Cloud before creating it",
|
|
131
131
|
)
|
|
132
|
+
create_parser.add_argument(
|
|
133
|
+
"-c",
|
|
134
|
+
"--config",
|
|
135
|
+
type=valid_config_file,
|
|
136
|
+
help="Use external config file.",
|
|
137
|
+
metavar="<path>",
|
|
138
|
+
default=None,
|
|
139
|
+
)
|
|
140
|
+
create_parser.add_argument(
|
|
141
|
+
"-e",
|
|
142
|
+
"--env",
|
|
143
|
+
type=str,
|
|
144
|
+
help="Desktop environment (e.g. kde)",
|
|
145
|
+
metavar="<env>",
|
|
146
|
+
default=None,
|
|
147
|
+
)
|
|
132
148
|
|
|
133
149
|
# Remove Parser
|
|
134
150
|
remove_parser = subparsers.add_parser(
|
|
@@ -117,6 +117,16 @@ def create_branch(repo: Repo, branch: str) -> None:
|
|
|
117
117
|
new_branch.checkout()
|
|
118
118
|
|
|
119
119
|
|
|
120
|
+
def create_empty_branch(repo: Repo, branch: str) -> None:
|
|
121
|
+
if repo.bare:
|
|
122
|
+
raise Exception("Error: The repository is bare. Cannot create a branch.")
|
|
123
|
+
repo.git.checkout("--orphan", branch)
|
|
124
|
+
repo.git.rm("-rf", ".")
|
|
125
|
+
has_commits = repo.head.is_valid() if repo.head else False
|
|
126
|
+
if not has_commits:
|
|
127
|
+
repo.index.commit("Initial commit for dotctl")
|
|
128
|
+
|
|
129
|
+
|
|
120
130
|
def checkout_branch(repo: Repo, branch: str) -> None:
|
|
121
131
|
local_profiles, remote_profiles, active_profile, all_profiles = get_repo_branches(
|
|
122
132
|
repo
|
|
@@ -109,7 +109,9 @@ class DotCtl:
|
|
|
109
109
|
|
|
110
110
|
def create_profile(self):
|
|
111
111
|
"""Create a new dotfiles profile."""
|
|
112
|
-
props = self._build_props(
|
|
112
|
+
props = self._build_props(
|
|
113
|
+
creator_default_props, "profile", "fetch", "config", "env"
|
|
114
|
+
)
|
|
113
115
|
create(props)
|
|
114
116
|
|
|
115
117
|
def remove_profile(self):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dotctl
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments.
|
|
5
5
|
Author-email: Pankaj Jackson <pankajackson@live.co.uk>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dotctl
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from git import Repo, GitCommandError, InvalidGitRepositoryError
|
|
5
|
-
from dotctl.paths import app_profile_directory
|
|
6
|
-
from dotctl.utils import log
|
|
7
|
-
from dotctl.exception import exception_handler
|
|
8
|
-
from dotctl.handlers.git_handler import (
|
|
9
|
-
get_repo,
|
|
10
|
-
get_repo_branches,
|
|
11
|
-
git_fetch,
|
|
12
|
-
create_branch,
|
|
13
|
-
)
|
|
14
|
-
from dotctl import __APP_NAME__, __DEFAULT_PROFILE__
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@dataclass
|
|
18
|
-
class CreatorProps:
|
|
19
|
-
profile: str
|
|
20
|
-
profile_dir: Path
|
|
21
|
-
fetch: bool
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
creator_default_props = CreatorProps(
|
|
25
|
-
profile=__DEFAULT_PROFILE__,
|
|
26
|
-
profile_dir=Path(app_profile_directory),
|
|
27
|
-
fetch=False,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@exception_handler
|
|
32
|
-
def create(props: CreatorProps):
|
|
33
|
-
log("Creating profile...")
|
|
34
|
-
repo = get_repo(props.profile_dir)
|
|
35
|
-
|
|
36
|
-
try:
|
|
37
|
-
if props.fetch:
|
|
38
|
-
git_fetch(repo)
|
|
39
|
-
|
|
40
|
-
_, _, _, all_profiles = get_repo_branches(repo)
|
|
41
|
-
if props.profile in all_profiles:
|
|
42
|
-
log(f"Profile '{props.profile}' already exists.")
|
|
43
|
-
return
|
|
44
|
-
create_branch(repo, props.profile)
|
|
45
|
-
log(f"Profile '{props.profile}' created and activated successfully.")
|
|
46
|
-
except Exception as e:
|
|
47
|
-
raise Exception(f"Unexpected error: {e}")
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export:
|
|
2
|
-
opt_folder:
|
|
3
|
-
entries:
|
|
4
|
-
- test-dots
|
|
5
|
-
location: /opt
|
|
6
|
-
save:
|
|
7
|
-
configs:
|
|
8
|
-
entries:
|
|
9
|
-
- composectl.yaml
|
|
10
|
-
location: $CONFIG_DIR
|
|
11
|
-
root_folder:
|
|
12
|
-
entries:
|
|
13
|
-
- rootdir
|
|
14
|
-
location: /root
|
|
15
|
-
root_folder2:
|
|
16
|
-
entries:
|
|
17
|
-
- rootdir2
|
|
18
|
-
location: /root
|
|
19
|
-
root_folder3:
|
|
20
|
-
entries:
|
|
21
|
-
- rootdir3
|
|
22
|
-
location: /root
|
|
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
|