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 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
- 162 passing (2m)
896
-
897
- --------------------|---------|----------|---------|---------|--------------------------------------
898
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
899
- --------------------|---------|----------|---------|---------|--------------------------------------
900
- All files | 81.62 | 68.94 | 83.57 | 81.53 |
901
- src | 57.62 | 53.75 | 55 | 58.11 |
902
- Command.js | 74.66 | 74.13 | 78.57 | 75.67 | ...5-62,73,80,93,127,164-172,179-182
903
- PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
904
- cliConfig.js | 100 | 100 | 100 | 100 |
905
- src/commands | 83.01 | 69.34 | 90.82 | 82.89 |
906
- Alias.js | 88.6 | 78.68 | 100 | 88.46 | 101,112,139,169,173,180,190,213-214
907
- Bash.js | 75 | 0 | 66.66 | 75 | 18-19
908
- Cat.js | 98.91 | 88.88 | 100 | 98.91 | 152
909
- Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
910
- Conf.js | 8.64 | 0 | 20 | 8.64 | 47-216
911
- Contacts.js | 86.06 | 75.6 | 100 | 85.95 | ...5,165,172,184,237,250,260,268-269
912
- Copy.js | 91.2 | 71.92 | 100 | 91.11 | 115,166,183,205-210,225-226,253
913
- Ds.js | 90.27 | 82.6 | 100 | 90.14 | 99,108-113,125,147-148
914
- Edit.js | 12.94 | 0 | 40 | 12.94 | 88-222
915
- Export.js | 90.17 | 76.92 | 100 | 90.17 | ...3-198,209,227-231,236,248,257,260
916
- Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
917
- Git.js | 92.3 | 66.66 | 100 | 92.3 | 40,61
918
- Help.js | 100 | 80 | 100 | 100 | 29
919
- Import.js | 92.41 | 85.38 | 100 | 92.34 | ...7,387,393,441,457-458,466-473,500
920
- Lcat.js | 100 | 85.71 | 100 | 100 | 54
921
- Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
922
- Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
923
- Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
924
- Ls.js | 91.54 | 76.31 | 100 | 91.04 | 103,114-116,130,185
925
- Mkdir.js | 92.59 | 60 | 100 | 92.59 | 56-57
926
- Mv.js | 86.59 | 71.66 | 100 | 86.31 | 93-99,133,155-156,165,175-182
927
- Paste.js | 84.61 | 70.83 | 100 | 84.61 | 72,78,81,89,113,130-131,139
928
- Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
929
- Quit.js | 90 | 50 | 100 | 90 | 27
930
- Rm.js | 90.9 | 76 | 100 | 90.74 | 63,125-126,136,144
931
- Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
932
- Show.js | 72.54 | 45.45 | 57.14 | 74 | ...8,100,106-114,117,123-126,132,145
933
- Ssh.js | 25 | 0 | 40 | 25 | 72-120
934
- Tag.js | 96.26 | 91.37 | 100 | 96.22 | 122,171,204-205
935
- Totp.js | 92.23 | 75 | 100 | 92.23 | 189-190,230,240,282-287,301-302
936
- Touch.js | 96.36 | 80.64 | 100 | 96.29 | 164,240
937
- Use.js | 91.66 | 86.95 | 100 | 91.66 | 68,83-84
938
- Ver.js | 90 | 66.66 | 100 | 90 | 25
939
- Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
940
- index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
941
- src/prompts | 75 | 33.33 | 50 | 75 |
942
- MainPromptMock.js | 75 | 33.33 | 50 | 75 | 29-35,44
943
- src/utils | 83.07 | 78.43 | 66.66 | 82.81 |
944
- AliasManager.js | 100 | 91.66 | 100 | 100 | 47
945
- ContactManager.js | 73.33 | 60 | 85.71 | 73.33 | 12,34-36
946
- HelpProto.js | 89.07 | 82.6 | 100 | 88.88 | 49,135-137,153-154,171-176,195
947
- Logger.js | 63.63 | 56.25 | 36.84 | 62.79 | ...25,37-49,57,65-69,74,84,88,93,105
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
- console.error(chalk.red.bold("\nāš ļø Installation Error\n"));
17
- console.error(
18
- chalk.yellow(
19
- "Secrez must be installed globally using pnpm.\n" +
20
- "It appears this package was installed with a different package manager.\n"
21
- )
22
- );
23
- console.error(chalk.white("\nPlease follow these steps:\n"));
24
- console.error(
25
- chalk.cyan(
26
- "1. Uninstall secrez using the package manager you previously used:\n" +
27
- " - If you used npm: " +
28
- chalk.bold("npm uninstall -g secrez") +
29
- "\n" +
30
- " - If you used yarn: " +
31
- chalk.bold("yarn global remove secrez") +
32
- "\n"
33
- )
34
- );
35
- console.error(
36
- chalk.cyan(
37
- "2. Install pnpm globally if you haven't already:\n" +
38
- " " +
39
- chalk.bold("npm install -g pnpm") +
40
- "\n"
41
- )
42
- );
43
- console.error(
44
- chalk.cyan("3. Setup pnpm:\n" + " " + chalk.bold("pnpm setup") + "\n")
45
- );
46
- console.error(
47
- chalk.cyan(
48
- "4. Install secrez globally using pnpm:\n" +
49
- " " +
50
- chalk.bold("pnpm install -g secrez") +
51
- "\n"
52
- )
53
- );
54
- process.exit(1);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secrez",
3
- "version": "2.1.13",
3
+ "version": "2.1.14",
4
4
  "license": "MIT",
5
5
  "nyc": {
6
6
  "include": "src",
@@ -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: ["Check a git repository status."],
28
- examples: [["git -s", "Check the git repository status"]],
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
  }