@secrez/fs 1.1.0 → 1.1.1

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/coverage.report +128 -124
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -25,7 +25,7 @@ API documentation
25
25
  - strengthen password-based export encryption in `FileCipher`: new **v2** format (PBKDF2, random salt in file, iterations out of band)
26
26
  - write vault blobs and cache files with mode `0o600` via `VaultPermissions` (FS-1)
27
27
  - add `fileCipherLegacy` module and `FileCipherLegacy` export for **v1** password-encrypted files (import compatibility and test fixtures)
28
- - require Node.js 20 or later (`engines.node >=20.0.0`)
28
+ - require Node.js 22.23.4 or later (`engines.node >=22.23.4`)
29
29
 
30
30
  **1.0.3**
31
31
 
@@ -38,7 +38,7 @@ API documentation
38
38
  ## Test coverage
39
39
 
40
40
  ```
41
- 108 passing (5s)
41
+ 108 passing (2s)
42
42
 
43
43
  -----------------------|---------|----------|---------|---------|-----------------------------------
44
44
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
package/coverage.report CHANGED
@@ -1,199 +1,203 @@
1
1
 
2
- > @secrez/fs@1.1.0 test /Users/francescosullo/Projects/Secrez/secrez/packages/fs
2
+ > @secrez/fs@1.0.7 test /Users/francescosullo/Projects/Secrez/secrez/packages/fs
3
3
  > cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js --exit
4
4
 
5
5
 
6
6
 
7
7
  #DataCache
8
- ✔ should initialize a dataCache
9
- ✔ should put and get data
10
- ✔ should load data from disk, if any
11
- ✔ should not load if no data
12
- ✔ should load plaintext data from disk, if any
13
- ✔ should load encrypted data from disk, if any
8
+ ✓ should initialize a dataCache
9
+ ✓ should put and get data
10
+ ✓ should load data from disk, if any
11
+ ✓ should not load if no data
12
+ ✓ should load plaintext data from disk, if any
13
+ ✓ should load encrypted data from disk, if any
14
14
 
15
15
  #ExternalFs
16
16
  getNormalizedPath
17
- ✔ should normalize "~/fileSystems"
18
- ✔ should normalize "~"
19
- ✔ should normalize "/var"
17
+ ✓ should normalize "~/fileSystems"
18
+ ✓ should normalize "~"
19
+ ✓ should normalize "/var"
20
20
  fileCompletion
21
- ✔ should return a list of files
22
- ✔ should return a list of only directories
23
- ✔ should return a list of only files
24
- ✔ should return the file itself, if it is not a directory
25
- ✔ should return the list of the files satisfying wildcards
26
- ✔ should return an empty list if the files does not exist
21
+ ✓ should return a list of files
22
+ ✓ should return a list of only directories
23
+ ✓ should return a list of only files
24
+ ✓ should return the file itself, if it is not a directory
25
+ ✓ should return the list of the files satisfying wildcards
26
+ ✓ should return an empty list if the files does not exist
27
27
  getVersionedBasename
28
- ✔ should version a file
28
+ ✓ should version a file
29
29
  isDir
30
- ✔ should confirm that "utils" is a dir
31
- ✔ should return that "config.test.js" is not a dir
32
- ✔ should return that a not-existent file is not a dir
30
+ ✓ should confirm that "utils" is a dir
31
+ ✓ should return that "config.test.js" is not a dir
32
+ ✓ should return that a not-existent file is not a dir
33
33
  isFile
34
- ✔ should return that "config.test.js" is a file
35
- ✔ should confirm that "utils" is not a file
36
- ✔ should return that a not-existent file is not a dir
34
+ ✓ should return that "config.test.js" is a file
35
+ ✓ should confirm that "utils" is not a file
36
+ ✓ should return that a not-existent file is not a dir
37
37
 
38
38
  #FileCipher
39
39
  encrypt/decrypt external file
40
- ✔ should encrypt a file using a specific password (v2)
41
- ✔ should decrypt v1 password-encrypted files
42
- ✔ should encrypt a file using a shared key
43
- ✔ should encrypt a file using user's own public key
40
+ ✓ should encrypt a file using a specific password
41
+ ✓ should encrypt a file using a shared key
42
+ ✓ should encrypt a file using user's own public key
44
43
 
45
44
  #FsUtils
46
45
  preParseCommandLine
47
- ✔ should preParse a command line
48
- ✔ should preParse a command line with escaped pars
49
- ✔ should preParse a command line using quotes for params
46
+ ✓ should preParse a command line
47
+ ✓ should preParse a command line with escaped pars
48
+ ✓ should preParse a command line using quotes for params
50
49
  parseCommandLine
51
- ✔ should parse a command line with definitions
52
- ✔ should return a {} w/out definitions
53
- ✔ should return a {} w/out params
54
- ✔ should return an _unknown if not supported option is passed
50
+ ✓ should parse a command line with definitions
51
+ ✓ should return a {} w/out definitions
52
+ ✓ should return a {} w/out params
53
+ ✓ should return an _unknown if not supported option is passed
55
54
  filterLs
56
- ✔ should filter an array of files and return itself
57
- ✔ should filter an array of files starting from "te"
58
- ✔ should filter an array of files of type .log
59
- ✔ should filter an array of files and find the folders
60
- ✔ should get all the files
61
- ✔ should return an empty array if nothing is found
62
- ✔ should return an empty array if parameters are missed or empty
63
- ✔ should return all the list array if files are missed
55
+ ✓ should filter an array of files and return itself
56
+ ✓ should filter an array of files starting from "te"
57
+ ✓ should filter an array of files of type .log
58
+ ✓ should filter an array of files and find the folders
59
+ ✓ should get all the files
60
+ ✓ should return an empty array if nothing is found
61
+ ✓ should return an empty array if parameters are missed or empty
62
+ ✓ should return all the list array if files are missed
64
63
 
65
64
  #GitConflictChecker
66
- ✔ should detect non-git repository
67
- ✔ should return null status for non-git repository
68
- ✔ should not detect conflict risk in non-git repository
69
- with local git repository
70
- ✔ should detect git repository
71
- ✔ should get git status when up to date with remote (73ms)
72
- ✔ should detect conflict risk when behind remote (164ms)
73
- ✔ should get warning message for conflict risk
74
- ✔ should not show alert again after user proceeds (73ms)
75
- ✔ should reset cache
65
+ ✓ should detect non-git repository
66
+ ✓ should return null status for non-git repository
67
+ ✓ should not detect conflict risk in non-git repository
68
+ with real GitHub repository
69
+ ✓ should detect git repository
70
+ ✓ should get git status when up to date with remote (3471ms)
71
+ ✓ should detect conflict risk when behind remote (5794ms)
72
+ ✓ should get warning message for conflict risk
73
+ ✓ should not show alert again after user proceeds (3582ms)
74
+ ✓ should reset cache
76
75
 
77
76
  #InternalFs
78
77
  #constructor
79
- ✔ should instantiate the internal file system and initialize it
80
- ✔ should initialize the internal fs
81
- ✔ should throw if passing not a Secrez instance
78
+ ✓ should instantiate the internal file system and initialize it
79
+ ✓ should initialize the internal fs
80
+ ✓ should throw if passing not a Secrez instance
82
81
  getFullPath
83
- ✔ should return the fullPath of an entry
82
+ ✓ should return the fullPath of an entry
84
83
  normalizePath
85
- ✔ should normalize a path
86
- ✔ should throw if the path is empty, is not a string or is longer than 255 chars
84
+ ✓ should normalize a path
85
+ ✓ should throw if the path is empty, is not a string or is longer than 255 chars
87
86
  getNormalizedPath
88
- ✔ should normalize a path
87
+ ✓ should normalize a path
89
88
  make
90
- ✔ should create directories and files
91
- ✔ should throw trying to re-add the same entry
89
+ ✓ should create directories and files
90
+ ✓ should throw trying to re-add the same entry
92
91
  change
93
- ✔ should create directories and files and update them
94
- ✔ should return an error
95
- ✔ should move files between datasets
92
+ ✓ should create directories and files and update them
93
+ ✓ should return an error
94
+ ✓ should move files between datasets
96
95
  remove
97
- ✔ should remove a file from the tree
96
+ ✓ should remove a file from the tree
98
97
  load
99
- ✔ should create directories and files and loading a tree from disk
100
- ✔ should create directories and files, and load a tree from disk
101
- ✔ should create directories and files, delete everything and loading a tree from disk
102
- ✔ should compress and reload an empty set of entries
98
+ ✓ should create directories and files and loading a tree from disk
99
+ ✓ should create directories and files, and load a tree from disk
100
+ ✓ should create directories and files, delete everything and loading a tree from disk
101
+ ✓ should compress and reload an empty set of entries
103
102
  #getFileList
104
- ✔ should get the current folder dir
103
+ ✓ should get the current folder dir
105
104
 
106
105
  #Node
107
106
  #constructor
108
- ✔ should instantiate the Node
109
- ✔ should throw if passing a rot without required parameters
110
- ✔ should throw if not passing an object
111
- ✔ should throw if not passing wrong type
107
+ ✓ should instantiate the Node
108
+ ✓ should throw if passing a rot without required parameters
109
+ ✓ should throw if not passing an object
110
+ ✓ should throw if not passing wrong type
112
111
  #getName && #getFile && #getContent && getOptions
113
- ✔ should get name, file and options
114
- ✔ should throw if version not found
112
+ ✓ should get name, file and options
113
+ ✓ should throw if version not found
115
114
  #getFindRe
116
- ✔ should get a re to check a filepath
115
+ ✓ should get a re to check a filepath
117
116
  #getNames
118
- ✔ should get the names of all children
119
- ✔ should throw if trying to get children of a file
117
+ ✓ should get the names of all children
118
+ ✓ should throw if trying to get children of a file
120
119
  #find
121
- ✔ should find all childrens satisfying criterias
120
+ ✓ should find all childrens satisfying criterias
122
121
  #add
123
- ✔ should add children to root
124
- ✔ should throw if node is a file
122
+ ✓ should add children to root
123
+ ✓ should throw if node is a file
125
124
  #move
126
- ✔ should rename a node
127
- ✔ should move a node
128
- ✔ should throw trying to move root
129
- ✔ should throw trying to modify a node with different id
125
+ ✓ should rename a node
126
+ ✓ should move a node
127
+ ✓ should throw trying to move root
128
+ ✓ should throw trying to modify a node with different id
130
129
  #remove
131
- ✔ should remove a node
132
- ✔ should remove itself
133
- ✔ should throw trying to remove root
130
+ ✓ should remove a node
131
+ ✓ should remove itself
132
+ ✓ should throw trying to remove root
134
133
  #toCompressedJSON && Node#fromJSON
135
- ✔ should prepare a json for saving
136
- ✔ should build an index from a json file
134
+ ✓ should prepare a json for saving
135
+ ✓ should build an index from a json file
137
136
  #getChildFromPath
138
- ✔ should find a node starting from a path
139
- ✔ should find the last ancestor starting from a path
140
- ✔ should throw if the path is incorrect or does not exist
141
- ✔ should throw if looking for last ancestor and find existent node
137
+ ✓ should find a node starting from a path
138
+ ✓ should find the last ancestor starting from a path
139
+ ✓ should throw if the path is incorrect or does not exist
140
+ ✓ should throw if looking for last ancestor and find existent node
142
141
  #getPathToChild
143
- ✔ should find a node starting from a path
144
- ✔ should throw if child is not a Node
145
- ✔ should throw if child belows to another tree
142
+ ✓ should find a node starting from a path
143
+ ✓ should throw if child is not a Node
144
+ ✓ should throw if child belows to another tree
146
145
  #findDirectChildByName && #findChildById
147
- ✔ should find a direct child by name and by id
148
- ✔ should throw if looking for child of a file
149
- ✔ should throw if looking for child of a file
146
+ ✓ should find a direct child by name and by id
147
+ ✓ should throw if looking for child of a file
148
+ ✓ should throw if looking for child of a file
150
149
 
151
150
  #Tree
152
151
  #constructor
153
- ✔ should instantiate the Tree
154
- ✔ should throw if passing not an Secrez instance
152
+ ✓ should instantiate the Tree
153
+ ✓ should throw if passing not an Secrez instance
155
154
  #load
156
- ✔ should load an empty Tree
157
- ✔ should do nothing if already loaded
155
+ ✓ should load an empty Tree
156
+ ✓ should do nothing if already loaded
158
157
  getEntryDetails
159
- ✔ should return the entry details of a node
158
+ ✓ should return the entry details of a node
160
159
  #Fix
161
- ✔ should load a tree with tags
160
+ ✓ should load a tree with tags (52ms)
162
161
  1) should simulate a conflict in the repo and recover lost entries when a valid tree exists
163
- ✔ should simulate a lost index in the repo and recover the entries when no valid tree is found
162
+ ✓ should simulate a lost index in the repo and recover the entries when no valid tree is found (73ms)
164
163
  Multi data sets
165
- ✔ should load the trees of two data sets
164
+ ✓ should load the trees of two data sets
166
165
 
167
166
 
168
- 107 passing (3s)
167
+ 106 passing (44s)
169
168
  1 failing
170
169
 
171
170
  1) #Tree
172
171
  #Fix
173
172
  should simulate a conflict in the repo and recover lost entries when a valid tree exists:
174
- RangeError: Invalid count value: -1
175
- at String.repeat (<anonymous>)
176
- at Crypto.getTimestampWithMicroseconds (/Users/francescosullo/Projects/Secrez/secrez/packages/crypto/src/index.js:417:39)
177
- at Secrez.encryptEntry (/Users/francescosullo/Projects/Secrez/secrez/packages/core/src/Secrez.js:228:20)
178
- at Tree.add (src/Tree.js:11:3592)
179
- at InternalFs.make (src/InternalFs.js:4:1671)
180
- at async Context.<anonymous> (test/Tree.test.js:253:7)
173
+
174
+ AssertionError: expected [ '/B/D/g', '/B/b', '/E/L/N', …(1) ] to deeply equal [ '/B/D/g', '/B/b', '/E/L/N', '/E/c' ]
175
+ + expected - actual
176
+
177
+ [
178
+ "/B/D/g"
179
+ "/B/b"
180
+ "/E/L/N"
181
+ - "/REC_20251009101127/d"
182
+ + "/E/c"
183
+ ]
184
+
185
+ at Context.<anonymous> (test/Tree.test.js:306:14)
181
186
 
182
187
 
183
188
 
184
189
  -----------------------|---------|----------|---------|---------|-----------------------------------
185
190
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
186
191
  -----------------------|---------|----------|---------|---------|-----------------------------------
187
- All files | 76.07 | 64.36 | 85.62 | 76.01 |
188
- DataCache.js | 89.53 | 74.07 | 90.9 | 89.41 | 18-24,123-124,150
192
+ All files | 81.85 | 67.77 | 86.27 | 81.52 |
193
+ DataCache.js | 89.41 | 74.07 | 90.9 | 89.28 | 17-23,122-123,149
189
194
  ExternalFs.js | 94.02 | 76.92 | 100 | 93.93 | 9,29,35,54
190
- FileCipher.js | 88.05 | 73.8 | 100 | 88.05 | 9,39,76,85,91,95,131,136
195
+ FileCipher.js | 88.63 | 73.33 | 100 | 88.63 | 8,52,80,85,94
191
196
  FsUtils.js | 100 | 100 | 100 | 100 |
192
197
  GitConflictChecker.js | 72.81 | 61.9 | 90 | 72.81 | ...95,204,222,254,259,277,289,308
193
- InternalFs.js | 82.35 | 70.83 | 85.18 | 82.21 | ...64,377-385,423-428,460,470-487
198
+ InternalFs.js | 85.09 | 71.87 | 85.18 | 84.98 | ...33,344,364,423-428,460,470-487
194
199
  Messages.js | 100 | 100 | 100 | 100 |
195
- Node.js | 65.81 | 53.7 | 78.72 | 65.02 | ...05,644-648,666,669,683-720,729
196
- Tree.js | 70.29 | 57.83 | 81.08 | 70.86 | ...44,471,481,535,627,635,666-677
197
- fileCipherLegacy.js | 100 | 100 | 100 | 100 |
200
+ Node.js | 66.1 | 54.81 | 78.72 | 65.31 | ...05,644-648,666,669,683-720,729
201
+ Tree.js | 90.19 | 74.09 | 86.48 | 89.91 | ...39,466,476,530,622,630,661-672
198
202
  -----------------------|---------|----------|---------|---------|-----------------------------------
199
203
   ELIFECYCLE  Test failed. See above for more details.
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@secrez/fs",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "dependencies": {
9
- "@secrez/core": "~1.1.0",
10
- "@secrez/crypto": "~1.1.0",
11
- "@secrez/utils": "~1.1.0",
9
+ "@secrez/core": "~1.1.1",
10
+ "@secrez/crypto": "~1.1.1",
11
+ "@secrez/utils": "~1.1.1",
12
12
  "command-line-args": "^5.2.1",
13
13
  "fs-extra": "^9.1.0",
14
14
  "lodash": "^4.17.21"
15
15
  },
16
16
  "devDependencies": {
17
- "@secrez/test-helpers": "~2.0.3",
17
+ "@secrez/test-helpers": "~2.0.4",
18
18
  "chai": "^4.5.0",
19
19
  "cross-env": "^7.0.3",
20
20
  "mocha": "^10.8.2",
@@ -31,7 +31,7 @@
31
31
  "email": "francesco@sullo.co"
32
32
  },
33
33
  "engines": {
34
- "node": ">=20.0.0"
34
+ "node": ">=22.23.4"
35
35
  },
36
36
  "scripts": {
37
37
  "all-tests": "find test/** -name '*.test.js' | xargs ./node_modules/.bin/mocha -R spec",