secrez 2.1.6 → 2.1.8
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/.env +9 -0
- package/README.md +64 -1
- package/coverage.report +45 -36
- package/package.json +3 -2
- package/src/Command.js +35 -0
- package/src/commands/Alias.js +15 -0
- package/src/commands/Conf.js +9 -0
- package/src/commands/Contacts.js +10 -0
- package/src/commands/Ds.js +10 -0
- package/src/commands/Edit.js +8 -0
- package/src/commands/Export.js +18 -2
- package/src/commands/Git.js +67 -0
- package/src/commands/Import.js +10 -0
- package/src/commands/Mkdir.js +10 -0
- package/src/commands/Mv.js +10 -0
- package/src/commands/Paste.js +10 -0
- package/src/commands/Rm.js +10 -0
- package/src/commands/Tag.js +10 -0
- package/src/commands/Totp.js +10 -0
- package/src/commands/Touch.js +9 -0
- package/src/commands/Use.js +10 -0
package/.env
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
SECREZ_TEST_REPO_URL="git@github.com:secrez/test-repo.git"
|
2
|
+
SECREZ_TEST_SSH_KEY="-----BEGIN OPENSSH PRIVATE KEY-----
|
3
|
+
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
4
|
+
QyNTUxOQAAACB8/5MMxGmWhwKsCKzu2bC2WhWdV6BiS/c2IVMJZ10NxQAAAKBOc1L6TnNS
|
5
|
+
+gAAAAtzc2gtZWQyNTUxOQAAACB8/5MMxGmWhwKsCKzu2bC2WhWdV6BiS/c2IVMJZ10NxQ
|
6
|
+
AAAEB8z+vtbfcUQyatLMOea+l7Ku4xbFbgB1Fyzymvo0T4Vnz/kwzEaZaHAqwIrO7ZsLZa
|
7
|
+
FZ1XoGJL9zYhUwlnXQ3FAAAAF3NlY3Jlei10ZXN0QGV4YW1wbGUuY29tAQIDBAUG
|
8
|
+
-----END OPENSSH PRIVATE KEY-----"
|
9
|
+
PUBLIC_TEST_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHz/kwzEaZaHAqwIrO7ZsLZaFZ1XoGJL9zYhUwlnXQ3F secrez-test@example.com"
|
package/README.md
CHANGED
@@ -152,6 +152,7 @@ Available commands:
|
|
152
152
|
edit Edits a file containing a secret.
|
153
153
|
export Export encrypted data to the OS in the current local folder
|
154
154
|
find Find a secret.
|
155
|
+
git Checks if there is a repo and if there are conflict risks.
|
155
156
|
help This help.
|
156
157
|
import Import files from the OS into the current folder
|
157
158
|
lcat Similar to a standard cat in the external fs.
|
@@ -369,6 +370,15 @@ Secrez is not intended to compete with password managers, so do not expect it to
|
|
369
370
|
|
370
371
|
## History
|
371
372
|
|
373
|
+
**2.1.8**
|
374
|
+
|
375
|
+
- add `git` command to check repository status and detect remote changes
|
376
|
+
- add git conflict detection middleware to prevent conflicts during data-changing operations
|
377
|
+
|
378
|
+
**2.1.7**
|
379
|
+
|
380
|
+
- add option `--no-export` to `export --crypto-env` to display the encrypted content in the console instead of writing it to a file
|
381
|
+
|
372
382
|
**2.1.6**
|
373
383
|
|
374
384
|
- export and encrypt, with option `--crypto-env`, the entire content of an item
|
@@ -861,7 +871,60 @@ Thank you for any contributions! 😉
|
|
861
871
|
## Test coverage
|
862
872
|
|
863
873
|
```
|
864
|
-
|
874
|
+
1 passing (549ms)
|
875
|
+
|
876
|
+
--------------------|---------|----------|---------|---------|--------------------------------------
|
877
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
878
|
+
--------------------|---------|----------|---------|---------|--------------------------------------
|
879
|
+
All files | 18.98 | 5.52 | 20.28 | 19.04 |
|
880
|
+
src | 30.39 | 14.49 | 21.05 | 30.69 |
|
881
|
+
Command.js | 32.2 | 21.27 | 30.76 | 32.75 | 22-35,40-97,102,108,119,122-130
|
882
|
+
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
883
|
+
cliConfig.js | 100 | 100 | 100 | 100 |
|
884
|
+
src/commands | 18.27 | 4.93 | 22.16 | 18.35 |
|
885
|
+
Alias.js | 8.1 | 0 | 25 | 8.21 | 62-213
|
886
|
+
Bash.js | 62.5 | 0 | 33.33 | 62.5 | 11-19
|
887
|
+
Cat.js | 29.67 | 17.46 | 42.85 | 29.67 | 61-93,98,110,117-142,150-169,178-220
|
888
|
+
Cd.js | 17.85 | 0 | 25 | 17.85 | 28-73
|
889
|
+
Conf.js | 7.79 | 0 | 10 | 7.79 | 67-500
|
890
|
+
Contacts.js | 5.98 | 0 | 7.69 | 6.03 | 53-274
|
891
|
+
Copy.js | 10.98 | 0 | 12.5 | 11.11 | 71-268
|
892
|
+
Ds.js | 5.97 | 0 | 16.66 | 6.06 | 39-160
|
893
|
+
Edit.js | 12.34 | 0 | 20 | 12.34 | 61-214
|
894
|
+
Export.js | 50 | 26.92 | 50 | 50 | ...8,209,219-295,301,307-308,316-323
|
895
|
+
Find.js | 7.69 | 0 | 8.33 | 7.89 | 63-211
|
896
|
+
Help.js | 33.33 | 0 | 50 | 33.33 | 26-43
|
897
|
+
Import.js | 6.31 | 0 | 9.09 | 6.37 | 87-496
|
898
|
+
Lcat.js | 30 | 0 | 25 | 30 | 35-65
|
899
|
+
Lcd.js | 17.39 | 0 | 25 | 17.39 | 30-72
|
900
|
+
Lls.js | 40.9 | 9.09 | 50 | 40.9 | 49,68,74-99
|
901
|
+
Lpwd.js | 38.46 | 0 | 50 | 38.46 | 15,29-38
|
902
|
+
Ls.js | 5.79 | 0 | 10 | 6.15 | 46-183
|
903
|
+
Mkdir.js | 22.72 | 0 | 25 | 22.72 | 27-61
|
904
|
+
Mv.js | 6.52 | 0 | 16.66 | 6.66 | 46-240
|
905
|
+
Paste.js | 14.89 | 0 | 25 | 14.89 | 40-131
|
906
|
+
Pwd.js | 30.76 | 0 | 25 | 30.76 | 15-35
|
907
|
+
Quit.js | 50 | 0 | 33.33 | 50 | 19-40
|
908
|
+
Rm.js | 16 | 0 | 16.66 | 16.32 | 36-137
|
909
|
+
Shell.js | 29.41 | 0 | 25 | 29.41 | 25-57
|
910
|
+
Show.js | 16 | 0 | 14.28 | 16.32 | 45-145
|
911
|
+
Ssh.js | 22.22 | 0 | 20 | 22.22 | 49-120
|
912
|
+
Tag.js | 8.82 | 0 | 9.09 | 8.91 | 66-236
|
913
|
+
Totp.js | 14.58 | 0 | 9.09 | 14.58 | 76-312
|
914
|
+
Touch.js | 76 | 51.85 | 75 | 75.51 | 75,140,152-158,164,168,177,231-234
|
915
|
+
Use.js | 12.9 | 0 | 25 | 12.9 | 30-85
|
916
|
+
Ver.js | 50 | 0 | 33.33 | 50 | 17-28
|
917
|
+
Whoami.js | 27.77 | 0 | 20 | 27.77 | 20-50
|
918
|
+
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
919
|
+
src/prompts | 100 | 100 | 33.33 | 100 |
|
920
|
+
MainPromptMock.js | 100 | 100 | 33.33 | 100 |
|
921
|
+
src/utils | 14.97 | 5.46 | 10.41 | 14.75 |
|
922
|
+
AliasManager.js | 5.88 | 0 | 0 | 5.88 | 3-48
|
923
|
+
ContactManager.js | 6.66 | 0 | 0 | 6.66 | 3-44
|
924
|
+
Fido2Client.js | 9.61 | 0 | 0 | 9.61 | 8-108
|
925
|
+
HelpProto.js | 4.2 | 0 | 16.66 | 4.27 | 11-200
|
926
|
+
Logger.js | 56.81 | 43.75 | 21.05 | 55.81 | ...16-29,37-57,65-69,74,84,88,93,105
|
927
|
+
--------------------|---------|----------|---------|---------|--------------------------------------
|
865
928
|
```
|
866
929
|
|
867
930
|
## Copyright
|
package/coverage.report
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> secrez@2.1.
|
2
|
+
> secrez@2.1.8 test /Users/francescosullo/Projects/Secrez/secrez/packages/secrez
|
3
3
|
> cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js test/**/**/*.js --exit
|
4
4
|
|
5
5
|
|
@@ -29,10 +29,10 @@
|
|
29
29
|
#Cat
|
30
30
|
✓ should return the help
|
31
31
|
✓ should show the content of a file
|
32
|
-
✓ should show either one or all the versions of a file (
|
32
|
+
✓ should show either one or all the versions of a file (1014ms)
|
33
33
|
✓ should throw if entry is not a file or file does not exist
|
34
34
|
✓ should throw if trying to cat a binary file
|
35
|
-
✓ should show the content of a Yaml file (
|
35
|
+
✓ should show the content of a Yaml file (1029ms)
|
36
36
|
|
37
37
|
#Cd
|
38
38
|
✓ should return the help
|
@@ -51,9 +51,9 @@
|
|
51
51
|
|
52
52
|
#Copy
|
53
53
|
✓ should return the help
|
54
|
-
✓ should copy a file to the clipboard (
|
55
|
-
✓ should copy a string to the clipboard (
|
56
|
-
✓ should copy a card to the clipboard (
|
54
|
+
✓ should copy a file to the clipboard (413ms)
|
55
|
+
✓ should copy a string to the clipboard (258ms)
|
56
|
+
✓ should copy a card to the clipboard (1001ms)
|
57
57
|
✓ should return an error if the file does not exist or is a folder (50ms)
|
58
58
|
✓ should throw if copying to clipboard a binary files
|
59
59
|
|
@@ -72,11 +72,12 @@
|
|
72
72
|
✓ should export an encrypted file to the current local folder
|
73
73
|
✓ should export a file and delete it after 1 second (1204ms)
|
74
74
|
✓ should return an error if the file does not exist or is a folder
|
75
|
-
✓ should export a keystore json file if a private_key exists in the entry (
|
75
|
+
✓ should export a keystore json file if a private_key exists in the entry (711ms)
|
76
76
|
✓ should export a cryptoenv file if a private_key exists in the entry
|
77
77
|
✓ should export a cryptoenv file with entire content when no private_key fields exist and user confirms
|
78
78
|
✓ should throw error when no private_key fields exist and user declines
|
79
79
|
✓ should throw error when no private_key fields exist and keystore option is used
|
80
|
+
✓ should display encrypted content in console when using crypto-env with no-export
|
80
81
|
|
81
82
|
#Find
|
82
83
|
✓ should return the help
|
@@ -84,6 +85,13 @@
|
|
84
85
|
✓ should find no result without parameters
|
85
86
|
✓ should skip binary files from search
|
86
87
|
|
88
|
+
#Git
|
89
|
+
✓ should return the help
|
90
|
+
✓ should show git status when --status is used (3396ms)
|
91
|
+
✓ should show git status by default (3521ms)
|
92
|
+
✓ should handle conflict risk scenario (5238ms)
|
93
|
+
✓ should handle non-git repository
|
94
|
+
|
87
95
|
#Help
|
88
96
|
✓ should return the help
|
89
97
|
✓ #execAsync and format
|
@@ -145,7 +153,7 @@
|
|
145
153
|
|
146
154
|
#Mv
|
147
155
|
✓ should return the help
|
148
|
-
✓ should rename a file (
|
156
|
+
✓ should rename a file (1014ms)
|
149
157
|
✓ should move a file to another folder
|
150
158
|
✓ should move many files to another folder
|
151
159
|
✓ should move a file to another subfolder
|
@@ -154,14 +162,14 @@
|
|
154
162
|
✓ should move file to another dataset using wildcards
|
155
163
|
✓ should move file managing duplicates
|
156
164
|
✓ should throw if parameters are missed or wrong
|
157
|
-
✓ should move files from and to other datasets (
|
165
|
+
✓ should move files from and to other datasets (1025ms)
|
158
166
|
✓ should move the results of a find
|
159
167
|
|
160
168
|
#Paste
|
161
169
|
✓ should return the help
|
162
|
-
✓ should paste the clipboard content to a new file (
|
163
|
-
✓ should paste the clipboard content to an existent file (
|
164
|
-
✓ should paste a single field to a yml card
|
170
|
+
✓ should paste the clipboard content to a new file (50ms)
|
171
|
+
✓ should paste the clipboard content to an existent file (70ms)
|
172
|
+
✓ should paste a single field to a yml card
|
165
173
|
|
166
174
|
#Pwd
|
167
175
|
✓ should return the help
|
@@ -195,13 +203,13 @@
|
|
195
203
|
|
196
204
|
#Totp
|
197
205
|
✓ should return the help
|
198
|
-
✓ should totp a file to the clipboard (
|
199
|
-
✓ should read a totp secret from an image and add the totp field to the card (
|
206
|
+
✓ should totp a file to the clipboard (407ms)
|
207
|
+
✓ should read a totp secret from an image and add the totp field to the card (39ms)
|
200
208
|
✓ should read a totp secret from an image and return the secret
|
201
209
|
✓ should throw if bad image
|
202
210
|
✓ should throw if missing parameters
|
203
211
|
✓ should throw if the yaml is malformed
|
204
|
-
✓ should read a totp secret from the clipboard (
|
212
|
+
✓ should read a totp secret from the clipboard (435ms)
|
205
213
|
|
206
214
|
#Touch
|
207
215
|
✓ should return the help
|
@@ -214,7 +222,7 @@
|
|
214
222
|
✓ should throw if wrong parameters
|
215
223
|
✓ should create a file and generate a wallet
|
216
224
|
New file "/folder2/file1" created.
|
217
|
-
✓ should generate 5 prefixed wallet (
|
225
|
+
✓ should generate 5 prefixed wallet (66ms)
|
218
226
|
New file "/folder2/file1" created.
|
219
227
|
✓ should generate a wallet with mnemonic and 2 keys
|
220
228
|
|
@@ -230,7 +238,7 @@ New file "/folder2/file1" created.
|
|
230
238
|
✓ should see who am I
|
231
239
|
|
232
240
|
|
233
|
-
|
241
|
+
160 passing (31s)
|
234
242
|
1 pending
|
235
243
|
1 failing
|
236
244
|
|
@@ -251,43 +259,44 @@ New file "/folder2/file1" created.
|
|
251
259
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
252
260
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
253
261
|
--------------------|---------|----------|---------|---------|--------------------------------------
|
254
|
-
All files |
|
255
|
-
src |
|
256
|
-
Command.js |
|
262
|
+
All files | 80.15 | 67.58 | 81.49 | 80.04 |
|
263
|
+
src | 55.75 | 52.05 | 55 | 56.25 |
|
264
|
+
Command.js | 72.85 | 74.5 | 78.57 | 73.91 | 32,55-62,73,80,119,145-156,163-166
|
257
265
|
PreCommand.js | 8.82 | 0 | 0 | 8.82 | 6-97
|
258
266
|
cliConfig.js | 100 | 100 | 100 | 100 |
|
259
|
-
src/commands |
|
260
|
-
Alias.js |
|
267
|
+
src/commands | 82.85 | 69.14 | 90.82 | 82.73 |
|
268
|
+
Alias.js | 88.6 | 78.68 | 100 | 88.46 | 101,112,139,169,173,180,190,213-214
|
261
269
|
Bash.js | 75 | 0 | 66.66 | 75 | 18-19
|
262
270
|
Cat.js | 98.9 | 88.88 | 100 | 98.9 | 152
|
263
271
|
Cd.js | 96.42 | 86.66 | 100 | 96.42 | 44
|
264
|
-
Conf.js |
|
265
|
-
Contacts.js |
|
272
|
+
Conf.js | 8.64 | 0 | 20 | 8.64 | 98-509
|
273
|
+
Contacts.js | 86.06 | 75.6 | 100 | 85.95 | ...5,165,172,184,237,250,260,268-269
|
266
274
|
Copy.js | 91.2 | 71.92 | 100 | 91.11 | 115,166,183,205-210,225-226,253
|
267
|
-
Ds.js |
|
268
|
-
Edit.js |
|
269
|
-
Export.js |
|
275
|
+
Ds.js | 90.27 | 82.6 | 100 | 90.14 | 99,108-113,125,147-148
|
276
|
+
Edit.js | 12.94 | 0 | 40 | 12.94 | 88-222
|
277
|
+
Export.js | 90.17 | 76.92 | 100 | 90.17 | ...3-198,209,227-231,236,248,257,260
|
270
278
|
Find.js | 93.58 | 86.66 | 100 | 93.42 | 101,164,200-203,209
|
279
|
+
Git.js | 92.3 | 66.66 | 100 | 92.3 | 40,61
|
271
280
|
Help.js | 100 | 80 | 100 | 100 | 29
|
272
|
-
Import.js |
|
281
|
+
Import.js | 92.41 | 85.38 | 100 | 92.34 | ...7,387,393,441,457-458,466-473,500
|
273
282
|
Lcat.js | 100 | 85.71 | 100 | 100 | 54
|
274
283
|
Lcd.js | 95.65 | 81.81 | 100 | 95.65 | 50
|
275
284
|
Lls.js | 95.45 | 72.72 | 100 | 95.45 | 97
|
276
285
|
Lpwd.js | 92.3 | 100 | 100 | 92.3 | 36
|
277
286
|
Ls.js | 91.3 | 75 | 100 | 90.76 | 103,114-116,130,181
|
278
|
-
Mkdir.js |
|
279
|
-
Mv.js |
|
280
|
-
Paste.js |
|
287
|
+
Mkdir.js | 92.59 | 60 | 100 | 92.59 | 56-57
|
288
|
+
Mv.js | 86.59 | 71.66 | 100 | 86.31 | 93-99,133,155-156,165,175-182
|
289
|
+
Paste.js | 84.61 | 70.83 | 100 | 84.61 | 72,78,81,89,113,130-131,139
|
281
290
|
Pwd.js | 92.3 | 100 | 100 | 92.3 | 33
|
282
291
|
Quit.js | 90 | 50 | 100 | 90 | 27
|
283
|
-
Rm.js |
|
292
|
+
Rm.js | 90.9 | 76 | 100 | 90.74 | 63,125-126,136,144
|
284
293
|
Shell.js | 88.23 | 60 | 100 | 88.23 | 38,55
|
285
294
|
Show.js | 72 | 45.45 | 57.14 | 73.46 | ...8,100,106-114,117,123-126,132,143
|
286
295
|
Ssh.js | 25 | 0 | 40 | 25 | 72-120
|
287
|
-
Tag.js |
|
288
|
-
Totp.js |
|
289
|
-
Touch.js |
|
290
|
-
Use.js |
|
296
|
+
Tag.js | 96.26 | 91.37 | 100 | 96.22 | 122,171,204-205
|
297
|
+
Totp.js | 92.07 | 74.19 | 100 | 92.07 | 189-190,230,240,282-287,301-302
|
298
|
+
Touch.js | 92.72 | 77.41 | 100 | 92.59 | 164,187-188,240
|
299
|
+
Use.js | 91.66 | 86.95 | 100 | 91.66 | 68,83-84
|
291
300
|
Ver.js | 90 | 66.66 | 100 | 90 | 25
|
292
301
|
Whoami.js | 83.33 | 60 | 80 | 83.33 | 27,35,48
|
293
302
|
index.js | 87.5 | 50 | 100 | 86.95 | 15,22,31
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "secrez",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.8",
|
4
4
|
"license": "MIT",
|
5
5
|
"nyc": {
|
6
6
|
"include": "src",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"@secrez/core": "~1.0.5",
|
11
11
|
"@secrez/crypto": "~1.0.4",
|
12
12
|
"@secrez/eth": "~0.0.4",
|
13
|
-
"@secrez/fs": "~1.0.
|
13
|
+
"@secrez/fs": "~1.0.6",
|
14
14
|
"@secrez/utils": "~1.0.4",
|
15
15
|
"case": "^1.6.3",
|
16
16
|
"chalk": "^3.0.0",
|
@@ -33,6 +33,7 @@
|
|
33
33
|
"chai": "^4.5.0",
|
34
34
|
"chalk": "^3.0.0",
|
35
35
|
"cross-env": "^7.0.3",
|
36
|
+
"dotenv": "^17.2.2",
|
36
37
|
"mocha": "^7.2.0",
|
37
38
|
"nyc": "^15.1.0",
|
38
39
|
"test-console": "^1.1.0"
|
package/src/Command.js
CHANGED
@@ -131,6 +131,41 @@ class Command extends PreCommand {
|
|
131
131
|
}
|
132
132
|
}
|
133
133
|
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Check for git conflicts before performing data-changing operations
|
137
|
+
* Returns true if the operation should proceed, false if it should be cancelled
|
138
|
+
*/
|
139
|
+
async checkGitConflictsBeforeOperation() {
|
140
|
+
try {
|
141
|
+
const conflictCheck = await this.internalFs.checkGitSyncStatus();
|
142
|
+
|
143
|
+
if (conflictCheck.hasRisk) {
|
144
|
+
// Show the warning message
|
145
|
+
this.Logger.yellow(conflictCheck.message);
|
146
|
+
|
147
|
+
// Ask user if they want to continue
|
148
|
+
const shouldContinue = await this.useInput({
|
149
|
+
type: "confirm",
|
150
|
+
message: "Do you want to continue anyway?",
|
151
|
+
default: false,
|
152
|
+
});
|
153
|
+
|
154
|
+
if (!shouldContinue) {
|
155
|
+
this.Logger.grey("Operation cancelled.");
|
156
|
+
return false;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
return true;
|
161
|
+
} catch (e) {
|
162
|
+
// If git check fails, log a warning but continue
|
163
|
+
this.Logger.yellow(
|
164
|
+
"Warning: Could not check git status. Proceeding anyway."
|
165
|
+
);
|
166
|
+
return true;
|
167
|
+
}
|
168
|
+
}
|
134
169
|
}
|
135
170
|
|
136
171
|
module.exports = Command;
|
package/src/commands/Alias.js
CHANGED
@@ -200,6 +200,21 @@ class Alias extends require("../Command") {
|
|
200
200
|
}
|
201
201
|
try {
|
202
202
|
this.validate(options);
|
203
|
+
|
204
|
+
// Check for git conflicts before creating/modifying/deleting aliases
|
205
|
+
if (
|
206
|
+
options.commandLine ||
|
207
|
+
options.previousCommand ||
|
208
|
+
options.rename ||
|
209
|
+
options.delete
|
210
|
+
) {
|
211
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
212
|
+
if (!shouldProceed) {
|
213
|
+
await this.prompt.run();
|
214
|
+
return;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
203
218
|
let result = await this.alias(options);
|
204
219
|
if (!Array.isArray(result)) {
|
205
220
|
result = [result];
|
package/src/commands/Conf.js
CHANGED
@@ -486,6 +486,15 @@ class Conf extends require("../Command") {
|
|
486
486
|
// options.list = true
|
487
487
|
// }
|
488
488
|
this.validate(options);
|
489
|
+
|
490
|
+
// Check for git conflicts before changing password or iterations
|
491
|
+
if (options.newPassword || options.newIterationsNumber) {
|
492
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
493
|
+
if (!shouldProceed) {
|
494
|
+
return;
|
495
|
+
}
|
496
|
+
}
|
497
|
+
|
489
498
|
// if (options.fido2 && options.recoveryCode) {
|
490
499
|
// throw new Error('Conflicting params. Launch "conf -h" for examples.')
|
491
500
|
// }
|
package/src/commands/Contacts.js
CHANGED
@@ -260,6 +260,16 @@ class Contacts extends require("../Command") {
|
|
260
260
|
options.list = true;
|
261
261
|
}
|
262
262
|
this.validate(options);
|
263
|
+
|
264
|
+
// Check for git conflicts before adding/updating/deleting contacts
|
265
|
+
if (options.add || options.update || options.delete || options.rename) {
|
266
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
267
|
+
if (!shouldProceed) {
|
268
|
+
await this.prompt.run();
|
269
|
+
return;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
263
273
|
let result = await this.contacts(options);
|
264
274
|
if (!Array.isArray(result)) {
|
265
275
|
result = [result];
|
package/src/commands/Ds.js
CHANGED
@@ -139,6 +139,16 @@ class Ds extends require("../Command") {
|
|
139
139
|
options.list = true;
|
140
140
|
}
|
141
141
|
this.validate(options);
|
142
|
+
|
143
|
+
// Check for git conflicts before creating/renaming/deleting datasets
|
144
|
+
if (options.create || options.rename || options.delete) {
|
145
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
146
|
+
if (!shouldProceed) {
|
147
|
+
await this.prompt.run();
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
142
152
|
let result = await this.ds(options);
|
143
153
|
if (result) {
|
144
154
|
if (options.list) {
|
package/src/commands/Edit.js
CHANGED
@@ -184,6 +184,14 @@ class Edit extends require("../Command") {
|
|
184
184
|
this.validate(options, {
|
185
185
|
path: true,
|
186
186
|
});
|
187
|
+
|
188
|
+
if (!options.help) {
|
189
|
+
// Check for git conflicts before editing files (edit always changes something)
|
190
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
191
|
+
if (!shouldProceed) {
|
192
|
+
return;
|
193
|
+
}
|
194
|
+
}
|
187
195
|
currentEditor = process.env.EDITOR;
|
188
196
|
if (options.internal) {
|
189
197
|
process.env.EDITOR = this.getTinyCliEditorBinPath();
|
package/src/commands/Export.js
CHANGED
@@ -71,6 +71,10 @@ class Export extends require("../Command") {
|
|
71
71
|
alias: "C",
|
72
72
|
type: Boolean,
|
73
73
|
},
|
74
|
+
{
|
75
|
+
name: "no-export",
|
76
|
+
type: Boolean,
|
77
|
+
},
|
74
78
|
];
|
75
79
|
}
|
76
80
|
|
@@ -115,6 +119,10 @@ class Export extends require("../Command") {
|
|
115
119
|
"export my-wallet.yml --crypto-env",
|
116
120
|
"it works like with keystore files, but it will export to file with .crypto.env extension ready to be used with @secrez/cryptoenv. Notice that the option -k has priority over -C.",
|
117
121
|
],
|
122
|
+
[
|
123
|
+
"export my-wallet.yml --crypto-env --no-export",
|
124
|
+
"encrypts the private key but displays it in console instead of exporting to file.",
|
125
|
+
],
|
118
126
|
],
|
119
127
|
};
|
120
128
|
}
|
@@ -202,6 +210,12 @@ class Export extends require("../Command") {
|
|
202
210
|
}
|
203
211
|
if (options.cryptoEnv) {
|
204
212
|
content = await Crypto.encrypt(privateKey, Crypto.SHA3(pwd));
|
213
|
+
if (options.noExport) {
|
214
|
+
// Display encrypted content in console instead of exporting
|
215
|
+
this.Logger.grey("Encrypted content:");
|
216
|
+
this.Logger.reset(content);
|
217
|
+
return null; // Return null to indicate no file was created
|
218
|
+
}
|
205
219
|
name = name.replace(/\.[^.]+$/, ".crypto.env");
|
206
220
|
} else {
|
207
221
|
content = await encryptPrivateKeyAsKeystoreJson(privateKey, pwd);
|
@@ -289,8 +303,10 @@ class Export extends require("../Command") {
|
|
289
303
|
try {
|
290
304
|
this.validate(options);
|
291
305
|
let name = await this.export(options);
|
292
|
-
|
293
|
-
|
306
|
+
if (name) {
|
307
|
+
this.Logger.grey("Exported file:");
|
308
|
+
this.Logger.reset(name);
|
309
|
+
}
|
294
310
|
if (
|
295
311
|
options.encrypt &&
|
296
312
|
!options.password &&
|
@@ -0,0 +1,67 @@
|
|
1
|
+
const chalk = require("chalk");
|
2
|
+
const { yamlStringify } = require("@secrez/utils");
|
3
|
+
|
4
|
+
class Git extends require("../Command") {
|
5
|
+
setHelpAndCompletion() {
|
6
|
+
this.cliConfig.completion.git = {
|
7
|
+
_func: this.selfCompletion(this),
|
8
|
+
_self: this,
|
9
|
+
};
|
10
|
+
this.cliConfig.completion.help.git = true;
|
11
|
+
this.optionDefinitions = [
|
12
|
+
{
|
13
|
+
name: "help",
|
14
|
+
alias: "h",
|
15
|
+
type: Boolean,
|
16
|
+
},
|
17
|
+
{
|
18
|
+
name: "status",
|
19
|
+
alias: "s",
|
20
|
+
type: Boolean,
|
21
|
+
},
|
22
|
+
];
|
23
|
+
}
|
24
|
+
|
25
|
+
help() {
|
26
|
+
return {
|
27
|
+
description: ["Check a git repository status."],
|
28
|
+
examples: [["git -s", "Check the git repository status"]],
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
32
|
+
async git(options = {}) {
|
33
|
+
const isGit = await this.internalFs.gitConflictChecker.isGitRepository();
|
34
|
+
if (isGit) {
|
35
|
+
if (options.status) {
|
36
|
+
let status = await this.internalFs.gitConflictChecker.getGitStatus();
|
37
|
+
let warning =
|
38
|
+
await this.internalFs.gitConflictChecker.getWarningMessage(status);
|
39
|
+
if (warning) {
|
40
|
+
return chalk.yellow(warning);
|
41
|
+
} else return "No remote changes found.";
|
42
|
+
}
|
43
|
+
} else {
|
44
|
+
return "Not a git repository";
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
async exec(options = {}) {
|
49
|
+
if (options.help) {
|
50
|
+
return this.showHelp();
|
51
|
+
}
|
52
|
+
try {
|
53
|
+
// if the user didn't pass any option, we default to options.status
|
54
|
+
if (!Object.keys(options).length) {
|
55
|
+
options.status = true;
|
56
|
+
}
|
57
|
+
this.validate(options);
|
58
|
+
let result = await this.git(options);
|
59
|
+
this.Logger.reset(result);
|
60
|
+
} catch (e) {
|
61
|
+
this.Logger.red(e.message);
|
62
|
+
}
|
63
|
+
await this.prompt.run();
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
module.exports = Git;
|
package/src/commands/Import.js
CHANGED
@@ -449,6 +449,16 @@ class Import extends require("../Command") {
|
|
449
449
|
}
|
450
450
|
try {
|
451
451
|
this.validate(options);
|
452
|
+
|
453
|
+
// Check for git conflicts before importing files (skip if help or simulate)
|
454
|
+
if (!options.help && !options.simulate) {
|
455
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
456
|
+
if (!shouldProceed) {
|
457
|
+
await this.prompt.run();
|
458
|
+
return;
|
459
|
+
}
|
460
|
+
}
|
461
|
+
|
452
462
|
if (options.expand) {
|
453
463
|
await this.expand(options);
|
454
464
|
} else {
|
package/src/commands/Mkdir.js
CHANGED
@@ -48,6 +48,16 @@ class Mkdir extends require("../Command") {
|
|
48
48
|
try {
|
49
49
|
this.validate(options);
|
50
50
|
this.checkPath(options);
|
51
|
+
|
52
|
+
// Check for git conflicts before creating directories
|
53
|
+
if (!options.help) {
|
54
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
55
|
+
if (!shouldProceed) {
|
56
|
+
await this.prompt.run();
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
51
61
|
let data = await this.internalFs.getTreeIndexAndPath(options.path);
|
52
62
|
let sanitizedPath = Entry.sanitizePath(data.path);
|
53
63
|
if (sanitizedPath !== data.path) {
|
package/src/commands/Mv.js
CHANGED
@@ -147,6 +147,16 @@ class Mv extends require("../Command") {
|
|
147
147
|
}
|
148
148
|
try {
|
149
149
|
this.validate(options);
|
150
|
+
|
151
|
+
// Check for git conflicts before moving/renaming files
|
152
|
+
if (!options.help) {
|
153
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
154
|
+
if (!shouldProceed) {
|
155
|
+
await this.prompt.run();
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
150
160
|
if (options.find) {
|
151
161
|
options.newPath = options.destination;
|
152
162
|
options.path = options.find;
|
package/src/commands/Paste.js
CHANGED
@@ -122,6 +122,16 @@ class Paste extends require("../Command") {
|
|
122
122
|
}
|
123
123
|
try {
|
124
124
|
this.validate(options);
|
125
|
+
|
126
|
+
// Check for git conflicts before pasting content
|
127
|
+
if (!options.help) {
|
128
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
129
|
+
if (!shouldProceed) {
|
130
|
+
await this.prompt.run();
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
125
135
|
let name = await this.paste(options);
|
126
136
|
this.Logger.grey("Pasted the clipboard to:");
|
127
137
|
this.Logger.reset(name);
|
package/src/commands/Rm.js
CHANGED
@@ -117,6 +117,16 @@ class Rm extends require("../Command") {
|
|
117
117
|
} else {
|
118
118
|
try {
|
119
119
|
this.validate(options);
|
120
|
+
|
121
|
+
// Check for git conflicts before removing files
|
122
|
+
if (!options.help) {
|
123
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
124
|
+
if (!shouldProceed) {
|
125
|
+
await this.prompt.run();
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
120
130
|
let deleted = await this.rm(options);
|
121
131
|
if (deleted.length === 0) {
|
122
132
|
this.Logger.grey("No files have been deleted.");
|
package/src/commands/Tag.js
CHANGED
@@ -196,6 +196,16 @@ class Tag extends require("../Command") {
|
|
196
196
|
}
|
197
197
|
try {
|
198
198
|
this.validate(options);
|
199
|
+
|
200
|
+
// Check for git conflicts before adding/removing tags
|
201
|
+
if (options.add || options.remove) {
|
202
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
203
|
+
if (!shouldProceed) {
|
204
|
+
await this.prompt.run();
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
199
209
|
let result = await this.tag(options);
|
200
210
|
if (options.list) {
|
201
211
|
if (options.global) {
|
package/src/commands/Totp.js
CHANGED
@@ -293,6 +293,16 @@ class Totp extends require("../Command") {
|
|
293
293
|
}
|
294
294
|
try {
|
295
295
|
this.validate(options);
|
296
|
+
|
297
|
+
// Check for git conflicts before setting TOTP secrets
|
298
|
+
if (options.set || options.fromClipboard || options.fromImage) {
|
299
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
300
|
+
if (!shouldProceed) {
|
301
|
+
await this.prompt.run();
|
302
|
+
return;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
296
306
|
let token = await this.totp(options);
|
297
307
|
if (options.fromImage || options.fromClipboard) {
|
298
308
|
this.Logger.grey(token);
|
package/src/commands/Touch.js
CHANGED
@@ -179,6 +179,15 @@ class Touch extends require("../Command") {
|
|
179
179
|
try {
|
180
180
|
this.validate(options);
|
181
181
|
this.checkPath(options);
|
182
|
+
|
183
|
+
// Check for git conflicts before creating/modifying files
|
184
|
+
if (!options.help) {
|
185
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
186
|
+
if (!shouldProceed) {
|
187
|
+
await this.prompt.run();
|
188
|
+
return;
|
189
|
+
}
|
190
|
+
}
|
182
191
|
/* istanbul ignore if */
|
183
192
|
if (!options.generateWallet) {
|
184
193
|
if (options.notVisibleContent) {
|
package/src/commands/Use.js
CHANGED
@@ -75,6 +75,16 @@ class Use extends require("../Command") {
|
|
75
75
|
}
|
76
76
|
try {
|
77
77
|
this.validate(options);
|
78
|
+
|
79
|
+
// Check for git conflicts before creating new datasets
|
80
|
+
if (options.create) {
|
81
|
+
const shouldProceed = await this.checkGitConflictsBeforeOperation();
|
82
|
+
if (!shouldProceed) {
|
83
|
+
await this.prompt.run();
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
78
88
|
let result = await this.use(options);
|
79
89
|
if (result) {
|
80
90
|
this.Logger.reset(result);
|