@sealant/mend 0.1.0 → 0.2.0
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.
- package/README.md +26 -8
- package/dist/dashboard.js +571 -0
- package/dist/dotfiles.js +90 -0
- package/dist/main.js +1177 -92
- package/dist/review-model.js +212 -0
- package/dist/review-workflow.js +15 -0
- package/dist/review.js +559 -0
- package/dist/service-init.js +227 -0
- package/dist/shared.js +50 -0
- package/dist/terminal.js +8 -0
- package/dist/tui-theme.js +25 -0
- package/package.json +10 -3
package/dist/dotfiles.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Local dotfiles scanning for `mend dotfiles sync`. This runs on the machine that HAS the
|
|
5
|
+
* files — the whole point: the Mend server may be a VPS whose home directory is a service
|
|
6
|
+
* account's, so contents are captured here and streamed to the server's per-user dotfiles store.
|
|
7
|
+
*
|
|
8
|
+
* The candidate list mirrors the product's curated set (plain configuration only — never keys,
|
|
9
|
+
* credential stores, or histories). The CLI stays dependency-light by design, so the list is
|
|
10
|
+
* duplicated here rather than imported from a workspace package.
|
|
11
|
+
*/
|
|
12
|
+
export const DOTFILE_CANDIDATES = [
|
|
13
|
+
{
|
|
14
|
+
group: "shell",
|
|
15
|
+
paths: [
|
|
16
|
+
".zshrc",
|
|
17
|
+
".zshenv",
|
|
18
|
+
".zprofile",
|
|
19
|
+
".bashrc",
|
|
20
|
+
".bash_profile",
|
|
21
|
+
".profile",
|
|
22
|
+
".aliases",
|
|
23
|
+
".config/fish/config.fish",
|
|
24
|
+
".config/starship.toml",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
group: "git",
|
|
29
|
+
paths: [".gitconfig", ".gitignore_global", ".config/git/config", ".config/git/ignore"],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
group: "editors",
|
|
33
|
+
paths: [".vimrc", ".ideavimrc", ".editorconfig", ".config/helix/config.toml"],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
group: "terminal",
|
|
37
|
+
paths: [".tmux.conf", ".config/tmux/tmux.conf", ".inputrc", ".dir_colors"],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
group: "tools",
|
|
41
|
+
paths: [
|
|
42
|
+
".ripgreprc",
|
|
43
|
+
".config/bat/config",
|
|
44
|
+
".config/lazygit/config.yml",
|
|
45
|
+
".config/mise/config.toml",
|
|
46
|
+
".config/atuin/config.toml",
|
|
47
|
+
".config/zellij/config.kdl",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
/** The per-file cap the server enforces; checked here so a mistake fails before the upload. */
|
|
52
|
+
export const MAX_FILE_BYTES = 1024 * 1024;
|
|
53
|
+
const statFile = (home, relative) => {
|
|
54
|
+
try {
|
|
55
|
+
const stat = fs.statSync(path.join(home, relative));
|
|
56
|
+
return stat.isFile() ? stat : null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/** Probe the curated candidates under `home`; only existing regular files appear. */
|
|
63
|
+
export const scanDotfileCandidates = (home) => DOTFILE_CANDIDATES.flatMap(({ group, paths }) => paths.flatMap((relative) => {
|
|
64
|
+
const stat = statFile(home, relative);
|
|
65
|
+
return stat === null ? [] : [{ path: relative, group, bytes: stat.size }];
|
|
66
|
+
}));
|
|
67
|
+
/**
|
|
68
|
+
* Read the selected paths for upload. Explicitly requested paths must exist (a typo should fail,
|
|
69
|
+
* not silently sync nothing); oversized files fail with the server's own rule. Modes ride along
|
|
70
|
+
* so an executable script stays executable.
|
|
71
|
+
*/
|
|
72
|
+
export const readSyncFiles = (home, paths_) => {
|
|
73
|
+
const files = [];
|
|
74
|
+
for (const relative of paths_) {
|
|
75
|
+
const stat = statFile(home, relative);
|
|
76
|
+
if (stat === null) {
|
|
77
|
+
return { error: `${relative} is not a file under ${home}` };
|
|
78
|
+
}
|
|
79
|
+
if (stat.size > MAX_FILE_BYTES) {
|
|
80
|
+
return { error: `${relative} is over 1MB — dotfiles are text; trim the selection` };
|
|
81
|
+
}
|
|
82
|
+
files.push({
|
|
83
|
+
path: relative,
|
|
84
|
+
contentsBase64: fs.readFileSync(path.join(home, relative)).toString("base64"),
|
|
85
|
+
// eslint-disable-next-line no-bitwise -- permission bits are the point
|
|
86
|
+
mode: (stat.mode & 0o777).toString(8),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return { files };
|
|
90
|
+
};
|