secrez 2.1.13 ā 2.1.14
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 +59 -54
- package/bin/secrez.js +42 -43
- package/package.json +1 -1
- package/src/commands/Git.js +56 -3
package/README.md
CHANGED
|
@@ -368,6 +368,11 @@ Secrez is not intended to compete with password managers, so do not expect it to
|
|
|
368
368
|
|
|
369
369
|
## History
|
|
370
370
|
|
|
371
|
+
**2.1.14**
|
|
372
|
+
|
|
373
|
+
- reverse changes done in version 2.1.12
|
|
374
|
+
- add a push option to Git that checks if there are changes in the repo and, if so, pushes them remotely, updating the system
|
|
375
|
+
|
|
371
376
|
**2.1.12**
|
|
372
377
|
|
|
373
378
|
- enforce the usage of pnpm during global install. When that is not possible, for example with yarn, it blocks the execution asking the user to uninstall and install it again properly
|
|
@@ -892,60 +897,60 @@ Thank you for any contributions! š
|
|
|
892
897
|
## Test coverage
|
|
893
898
|
|
|
894
899
|
```
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
899
|
-
|
|
900
|
-
All files |
|
|
901
|
-
src |
|
|
902
|
-
Command.js |
|
|
903
|
-
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
|
904
|
-
cliConfig.js | 100 | 100 | 100 | 100 |
|
|
905
|
-
src/commands |
|
|
906
|
-
Alias.js |
|
|
907
|
-
Bash.js |
|
|
908
|
-
Cat.js |
|
|
909
|
-
Cd.js |
|
|
910
|
-
Conf.js |
|
|
911
|
-
Contacts.js |
|
|
912
|
-
Copy.js |
|
|
913
|
-
Ds.js |
|
|
914
|
-
Edit.js |
|
|
915
|
-
Export.js |
|
|
916
|
-
Find.js |
|
|
917
|
-
Git.js |
|
|
918
|
-
Help.js |
|
|
919
|
-
Import.js |
|
|
920
|
-
Lcat.js |
|
|
921
|
-
Lcd.js |
|
|
922
|
-
Lls.js |
|
|
923
|
-
Lpwd.js |
|
|
924
|
-
Ls.js |
|
|
925
|
-
Mkdir.js |
|
|
926
|
-
Mv.js |
|
|
927
|
-
Paste.js |
|
|
928
|
-
Pwd.js |
|
|
929
|
-
Quit.js |
|
|
930
|
-
Rm.js |
|
|
931
|
-
Shell.js |
|
|
932
|
-
Show.js |
|
|
933
|
-
Ssh.js |
|
|
934
|
-
Tag.js |
|
|
935
|
-
Totp.js |
|
|
936
|
-
Touch.js |
|
|
937
|
-
Use.js |
|
|
938
|
-
Ver.js |
|
|
939
|
-
Whoami.js |
|
|
940
|
-
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
|
941
|
-
src/prompts |
|
|
942
|
-
MainPromptMock.js |
|
|
943
|
-
src/utils |
|
|
944
|
-
AliasManager.js |
|
|
945
|
-
ContactManager.js |
|
|
946
|
-
HelpProto.js |
|
|
947
|
-
Logger.js |
|
|
948
|
-
|
|
900
|
+
1 passing (15s)
|
|
901
|
+
|
|
902
|
+
--------------------|---------|----------|---------|---------|----------------------------------
|
|
903
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
904
|
+
--------------------|---------|----------|---------|---------|----------------------------------
|
|
905
|
+
All files | 14.72 | 2.34 | 17.88 | 14.78 |
|
|
906
|
+
src | 25.42 | 6.25 | 15 | 25.64 |
|
|
907
|
+
Command.js | 24 | 8.62 | 21.42 | 24.32 | 22-35,40-110,116,127,130-182
|
|
908
|
+
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
|
909
|
+
cliConfig.js | 100 | 100 | 100 | 100 |
|
|
910
|
+
src/commands | 13.44 | 1.7 | 19.32 | 13.52 |
|
|
911
|
+
Alias.js | 7.59 | 0 | 25 | 7.69 | 62-228
|
|
912
|
+
Bash.js | 62.5 | 0 | 33.33 | 62.5 | 11-19
|
|
913
|
+
Cat.js | 11.95 | 0 | 14.28 | 11.95 | 61-222
|
|
914
|
+
Cd.js | 17.85 | 0 | 25 | 17.85 | 28-73
|
|
915
|
+
Conf.js | 7.4 | 0 | 10 | 7.4 | 34-216
|
|
916
|
+
Contacts.js | 5.73 | 0 | 7.69 | 5.78 | 53-284
|
|
917
|
+
Copy.js | 10.98 | 0 | 12.5 | 11.11 | 71-268
|
|
918
|
+
Ds.js | 5.55 | 0 | 16.66 | 5.63 | 39-170
|
|
919
|
+
Edit.js | 11.76 | 0 | 20 | 11.76 | 61-222
|
|
920
|
+
Export.js | 9.82 | 0 | 16.66 | 9.82 | 82-325
|
|
921
|
+
Find.js | 7.69 | 0 | 8.33 | 7.89 | 63-211
|
|
922
|
+
Git.js | 48.88 | 35.71 | 75 | 48.88 | 31,49-54,61,70-97,103,108,114
|
|
923
|
+
Help.js | 33.33 | 0 | 50 | 33.33 | 26-43
|
|
924
|
+
Import.js | 6.16 | 0 | 9.09 | 6.22 | 87-506
|
|
925
|
+
Lcat.js | 30 | 0 | 25 | 30 | 35-65
|
|
926
|
+
Lcd.js | 17.39 | 0 | 25 | 17.39 | 30-72
|
|
927
|
+
Lls.js | 22.72 | 0 | 25 | 22.72 | 49-99
|
|
928
|
+
Lpwd.js | 30.76 | 0 | 25 | 30.76 | 15-38
|
|
929
|
+
Ls.js | 5.63 | 0 | 10 | 5.97 | 46-187
|
|
930
|
+
Mkdir.js | 18.51 | 0 | 25 | 18.51 | 27-71
|
|
931
|
+
Mv.js | 6.18 | 0 | 16.66 | 6.31 | 46-250
|
|
932
|
+
Paste.js | 13.46 | 0 | 25 | 13.46 | 40-141
|
|
933
|
+
Pwd.js | 30.76 | 0 | 25 | 30.76 | 15-35
|
|
934
|
+
Quit.js | 50 | 0 | 33.33 | 50 | 19-40
|
|
935
|
+
Rm.js | 14.54 | 0 | 16.66 | 14.81 | 36-147
|
|
936
|
+
Shell.js | 29.41 | 0 | 25 | 29.41 | 25-57
|
|
937
|
+
Show.js | 15.68 | 0 | 14.28 | 16 | 45-147
|
|
938
|
+
Ssh.js | 22.22 | 0 | 20 | 22.22 | 49-120
|
|
939
|
+
Tag.js | 8.41 | 0 | 9.09 | 8.49 | 66-246
|
|
940
|
+
Totp.js | 13.59 | 0 | 9.09 | 13.59 | 76-327
|
|
941
|
+
Touch.js | 14.54 | 0 | 25 | 14.81 | 75-245
|
|
942
|
+
Use.js | 11.11 | 0 | 25 | 11.11 | 30-95
|
|
943
|
+
Ver.js | 50 | 0 | 33.33 | 50 | 17-28
|
|
944
|
+
Whoami.js | 27.77 | 0 | 20 | 27.77 | 20-50
|
|
945
|
+
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
|
946
|
+
src/prompts | 58.33 | 0 | 25 | 58.33 |
|
|
947
|
+
MainPromptMock.js | 58.33 | 0 | 25 | 58.33 | 22-44
|
|
948
|
+
src/utils | 15.89 | 6.86 | 10.25 | 15.62 |
|
|
949
|
+
AliasManager.js | 5.88 | 0 | 0 | 5.88 | 3-48
|
|
950
|
+
ContactManager.js | 6.66 | 0 | 0 | 6.66 | 3-44
|
|
951
|
+
HelpProto.js | 4.2 | 0 | 16.66 | 4.27 | 11-200
|
|
952
|
+
Logger.js | 54.54 | 43.75 | 15.78 | 53.48 | 8,12,16-57,65-69,74,84,88,93,105
|
|
953
|
+
--------------------|---------|----------|---------|---------|----------------------------------
|
|
949
954
|
```
|
|
950
955
|
|
|
951
956
|
## Copyright
|
package/bin/secrez.js
CHANGED
|
@@ -9,50 +9,49 @@ const pkg = require("../package");
|
|
|
9
9
|
|
|
10
10
|
const MainPrompt = require("../src/prompts/MainPrompt");
|
|
11
11
|
const Logger = require("../src/utils/Logger");
|
|
12
|
-
|
|
13
12
|
// Check if the package was installed with pnpm (skip check in development)
|
|
14
|
-
const installPath = __dirname;
|
|
15
|
-
if (process.env.NODE_ENV !== "dev" && installPath.indexOf("pnpm") === -1) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
13
|
+
// const installPath = __dirname;
|
|
14
|
+
// if (process.env.NODE_ENV !== "dev" && installPath.indexOf("pnpm") === -1) {
|
|
15
|
+
// console.error(chalk.red.bold("\nā ļø Installation Error\n"));
|
|
16
|
+
// console.error(
|
|
17
|
+
// chalk.yellow(
|
|
18
|
+
// "Secrez must be installed globally using pnpm.\n" +
|
|
19
|
+
// "It appears this package was installed with a different package manager.\n"
|
|
20
|
+
// )
|
|
21
|
+
// );
|
|
22
|
+
// console.error(chalk.white("\nPlease follow these steps:\n"));
|
|
23
|
+
// console.error(
|
|
24
|
+
// chalk.cyan(
|
|
25
|
+
// "1. Uninstall secrez using the package manager you previously used:\n" +
|
|
26
|
+
// " - If you used npm: " +
|
|
27
|
+
// chalk.bold("npm uninstall -g secrez") +
|
|
28
|
+
// "\n" +
|
|
29
|
+
// " - If you used yarn: " +
|
|
30
|
+
// chalk.bold("yarn global remove secrez") +
|
|
31
|
+
// "\n"
|
|
32
|
+
// )
|
|
33
|
+
// );
|
|
34
|
+
// console.error(
|
|
35
|
+
// chalk.cyan(
|
|
36
|
+
// "2. Install pnpm globally if you haven't already:\n" +
|
|
37
|
+
// " " +
|
|
38
|
+
// chalk.bold("npm install -g pnpm") +
|
|
39
|
+
// "\n"
|
|
40
|
+
// )
|
|
41
|
+
// );
|
|
42
|
+
// console.error(
|
|
43
|
+
// chalk.cyan("3. Setup pnpm:\n" + " " + chalk.bold("pnpm setup") + "\n")
|
|
44
|
+
// );
|
|
45
|
+
// console.error(
|
|
46
|
+
// chalk.cyan(
|
|
47
|
+
// "4. Install secrez globally using pnpm:\n" +
|
|
48
|
+
// " " +
|
|
49
|
+
// chalk.bold("pnpm install -g secrez") +
|
|
50
|
+
// "\n"
|
|
51
|
+
// )
|
|
52
|
+
// );
|
|
53
|
+
// process.exit(1);
|
|
54
|
+
// }
|
|
56
55
|
|
|
57
56
|
const optionDefinitions = [
|
|
58
57
|
{
|
package/package.json
CHANGED
package/src/commands/Git.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const chalk = require("chalk");
|
|
2
|
-
const { yamlStringify } = require("@secrez/utils");
|
|
2
|
+
const { yamlStringify, execAsync } = require("@secrez/utils");
|
|
3
3
|
|
|
4
4
|
class Git extends require("../Command") {
|
|
5
5
|
setHelpAndCompletion() {
|
|
@@ -19,13 +19,26 @@ class Git extends require("../Command") {
|
|
|
19
19
|
alias: "s",
|
|
20
20
|
type: Boolean,
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
name: "push",
|
|
24
|
+
alias: "p",
|
|
25
|
+
type: Boolean,
|
|
26
|
+
},
|
|
22
27
|
];
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
help() {
|
|
26
31
|
return {
|
|
27
|
-
description: [
|
|
28
|
-
|
|
32
|
+
description: [
|
|
33
|
+
"Check a git repository status or push current changes and update the fingerprint.",
|
|
34
|
+
],
|
|
35
|
+
examples: [
|
|
36
|
+
["git -s", "Check the git repository status"],
|
|
37
|
+
[
|
|
38
|
+
"git -p",
|
|
39
|
+
"Stage, commit (if needed), push changes, and update the fingerprint",
|
|
40
|
+
],
|
|
41
|
+
],
|
|
29
42
|
};
|
|
30
43
|
}
|
|
31
44
|
|
|
@@ -40,6 +53,46 @@ class Git extends require("../Command") {
|
|
|
40
53
|
return chalk.yellow(warning);
|
|
41
54
|
} else return "No remote changes found.";
|
|
42
55
|
}
|
|
56
|
+
if (options.push) {
|
|
57
|
+
const containerPath = this.secrez.config.container;
|
|
58
|
+
// Get current status to know what to do
|
|
59
|
+
const status = await this.internalFs.gitConflictChecker.getGitStatus();
|
|
60
|
+
if (status && status.error) {
|
|
61
|
+
return chalk.red(`Git status error: ${status.error}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// No changes and not ahead: nothing to push
|
|
65
|
+
if ((status?.uncommitted || 0) === 0 && (status?.ahead || 0) === 0) {
|
|
66
|
+
return "No changes in the repository";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// If there are uncommitted changes, stage and commit
|
|
70
|
+
if (status && status.uncommitted > 0) {
|
|
71
|
+
const addRes = await execAsync("git", containerPath, ["add", "-A"]);
|
|
72
|
+
if (addRes && addRes.error) {
|
|
73
|
+
return chalk.red(`git add failed: ${addRes.error}`);
|
|
74
|
+
}
|
|
75
|
+
const commitRes = await execAsync("git", containerPath, [
|
|
76
|
+
"commit",
|
|
77
|
+
"-m",
|
|
78
|
+
"Secrez: save changes",
|
|
79
|
+
]);
|
|
80
|
+
if (commitRes && commitRes.error) {
|
|
81
|
+
return chalk.red(`git commit failed: ${commitRes.error}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Try to push (even if there were no new commits but local might be ahead)
|
|
86
|
+
const pushRes = await execAsync("git", containerPath, ["push"]);
|
|
87
|
+
if (pushRes && pushRes.error) {
|
|
88
|
+
return chalk.red(`git push failed: ${pushRes.error}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Update the initial fingerprint so Secrez won't block further operations in this session
|
|
92
|
+
await this.internalFs.gitConflictChecker.captureInitialState();
|
|
93
|
+
|
|
94
|
+
return "Pushed successfully. Fingerprint updated.";
|
|
95
|
+
}
|
|
43
96
|
} else {
|
|
44
97
|
return "Not a git repository";
|
|
45
98
|
}
|