@secrez/fs 1.0.3 β 1.0.5
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/LICENSE +0 -0
- package/README.md +28 -28
- package/coverage.report +167 -180
- package/package.json +41 -44
- package/src/DataCache.js +64 -66
- package/src/ExternalFs.js +64 -58
- package/src/FileCipher.js +50 -42
- package/src/FsUtils.js +47 -44
- package/src/InternalFs.js +253 -239
- package/src/Messages.js +2 -2
- package/src/Node.js +305 -308
- package/src/Tree.js +340 -318
- package/src/index.js +9 -9
- package/.eslintignore +0 -0
- package/.eslintrc +0 -33
- package/.jshintrc +0 -3
- package/pnpm-lock.yaml +0 -2307
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ This is the filesystem component.
|
|
|
6
6
|
|
|
7
7
|
@secrez/fs exposes:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
- InternalFs
|
|
10
|
+
- ExternalFs
|
|
11
|
+
- FsUtils
|
|
12
|
+
- Tree
|
|
13
|
+
- Node
|
|
14
|
+
- DataCache
|
|
15
|
+
- FileCipher (starting from 1.0.3)
|
|
16
16
|
|
|
17
17
|
## TODO
|
|
18
18
|
|
|
@@ -20,33 +20,34 @@ API documentation
|
|
|
20
20
|
|
|
21
21
|
## History
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
* Move `encryptFile` and `decryptFile` from ExternalFs to FileCipher
|
|
23
|
+
**1.0.3**
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
- Move `encryptFile` and `decryptFile` from ExternalFs to FileCipher
|
|
26
|
+
|
|
27
|
+
**1.0.2**
|
|
28
|
+
|
|
29
|
+
- Adds `encryptFile` and `decryptFile` to ExternalFs
|
|
28
30
|
|
|
29
31
|
## Test coverage
|
|
30
32
|
|
|
31
33
|
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
36
|
-
|
|
37
|
-
All files |
|
|
38
|
-
DataCache.js |
|
|
39
|
-
ExternalFs.js |
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
98 passing (3s)
|
|
35
|
+
|
|
36
|
+
---------------|---------|----------|---------|---------|-------------------------------------------
|
|
37
|
+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
38
|
+
---------------|---------|----------|---------|---------|-------------------------------------------
|
|
39
|
+
All files | 82.9 | 68.72 | 86.61 | 82.56 |
|
|
40
|
+
DataCache.js | 89.41 | 74.07 | 90.9 | 89.28 | 17-23,122-123,149
|
|
41
|
+
ExternalFs.js | 94.02 | 76.92 | 100 | 93.93 | 9,29,35,54
|
|
42
|
+
FileCipher.js | 88.63 | 73.33 | 100 | 88.63 | 8,52,80,85,94
|
|
43
|
+
FsUtils.js | 100 | 100 | 100 | 100 |
|
|
44
|
+
InternalFs.js | 86.99 | 72.63 | 88.46 | 86.88 | ...25,257,274,283,328,339,359,418-423,455
|
|
45
|
+
Messages.js | 100 | 100 | 100 | 100 |
|
|
46
|
+
Node.js | 66.1 | 54.81 | 78.72 | 65.31 | ...67,579-605,644-648,666,669,683-720,729
|
|
47
|
+
Tree.js | 89.91 | 74.09 | 86.48 | 89.63 | ...72,417-439,466,476,530,622,630,661-672
|
|
48
|
+
---------------|---------|----------|---------|---------|-------------------------------------------
|
|
47
49
|
```
|
|
48
50
|
|
|
49
|
-
|
|
50
51
|
## Copyright
|
|
51
52
|
|
|
52
53
|
(c) 2020-present [Francesco Sullo](https://francesco.sullo.co) (<francesco@sullo.co>)
|
|
@@ -54,4 +55,3 @@ All files | 6.92 | 3.88 | 4.26 | 7.07 |
|
|
|
54
55
|
## Licence
|
|
55
56
|
|
|
56
57
|
MIT
|
|
57
|
-
|
package/coverage.report
CHANGED
|
@@ -1,186 +1,173 @@
|
|
|
1
1
|
|
|
2
|
-
> @secrez/fs@1.0.
|
|
3
|
-
> cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
[31m 1 failing[0m
|
|
157
|
-
|
|
158
|
-
[0m 1) #Tree
|
|
159
|
-
#Fix
|
|
160
|
-
should simulate a conflict in the repo and recover lost entries:
|
|
161
|
-
|
|
162
|
-
[31mAssertionError: expected 6 to equal 5[0m
|
|
163
|
-
[32m+ expected[0m [31m- actual[0m
|
|
164
|
-
|
|
165
|
-
[31m-6[0m
|
|
166
|
-
[32m+5[0m
|
|
167
|
-
[0m[90m
|
|
168
|
-
at Context.<anonymous> (test/Tree.test.js:330:14)
|
|
169
|
-
[0m
|
|
170
|
-
|
|
2
|
+
> @secrez/fs@1.0.5 test /Users/francescosullo/Projects/Secrez/secrez/packages/fs
|
|
3
|
+
> cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js --exit
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
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
|
|
14
|
+
|
|
15
|
+
#ExternalFs
|
|
16
|
+
getNormalizedPath
|
|
17
|
+
β should normalize "~/fileSystems"
|
|
18
|
+
β should normalize "~"
|
|
19
|
+
β should normalize "/var"
|
|
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
|
|
27
|
+
getVersionedBasename
|
|
28
|
+
β should version a file
|
|
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
|
|
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
|
|
37
|
+
|
|
38
|
+
#FileCipher
|
|
39
|
+
encrypt/decrypt external file
|
|
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
|
|
43
|
+
|
|
44
|
+
#FsUtils
|
|
45
|
+
preParseCommandLine
|
|
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
|
|
49
|
+
parseCommandLine
|
|
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
|
|
54
|
+
filterLs
|
|
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
|
|
63
|
+
|
|
64
|
+
#InternalFs
|
|
65
|
+
#constructor
|
|
66
|
+
β should instantiate the internal file system and initialize it
|
|
67
|
+
β should initialize the internal fs
|
|
68
|
+
β should throw if passing not a Secrez instance
|
|
69
|
+
getFullPath
|
|
70
|
+
β should return the fullPath of an entry
|
|
71
|
+
normalizePath
|
|
72
|
+
β should normalize a path
|
|
73
|
+
β should throw if the path is empty, is not a string or is longer than 255 chars
|
|
74
|
+
getNormalizedPath
|
|
75
|
+
β should normalize a path
|
|
76
|
+
make
|
|
77
|
+
β should create directories and files
|
|
78
|
+
β should throw trying to re-add the same entry
|
|
79
|
+
change
|
|
80
|
+
β should create directories and files and update them
|
|
81
|
+
β should return an error
|
|
82
|
+
β should move files between datasets
|
|
83
|
+
remove
|
|
84
|
+
β should remove a file from the tree
|
|
85
|
+
load
|
|
86
|
+
β should create directories and files and loading a tree from disk
|
|
87
|
+
β should create directories and files, and load a tree from disk
|
|
88
|
+
β should create directories and files, delete everything and loading a tree from disk
|
|
89
|
+
β should compress and reload an empty set of entries
|
|
90
|
+
#getFileList
|
|
91
|
+
β should get the current folder dir
|
|
92
|
+
|
|
93
|
+
#Node
|
|
94
|
+
#constructor
|
|
95
|
+
β should instantiate the Node
|
|
96
|
+
β should throw if passing a rot without required parameters
|
|
97
|
+
β should throw if not passing an object
|
|
98
|
+
β should throw if not passing wrong type
|
|
99
|
+
#getName && #getFile && #getContent && getOptions
|
|
100
|
+
β should get name, file and options
|
|
101
|
+
β should throw if version not found
|
|
102
|
+
#getFindRe
|
|
103
|
+
β should get a re to check a filepath
|
|
104
|
+
#getNames
|
|
105
|
+
β should get the names of all children
|
|
106
|
+
β should throw if trying to get children of a file
|
|
107
|
+
#find
|
|
108
|
+
β should find all childrens satisfying criterias
|
|
109
|
+
#add
|
|
110
|
+
β should add children to root
|
|
111
|
+
β should throw if node is a file
|
|
112
|
+
#move
|
|
113
|
+
β should rename a node
|
|
114
|
+
β should move a node
|
|
115
|
+
β should throw trying to move root
|
|
116
|
+
β should throw trying to modify a node with different id
|
|
117
|
+
#remove
|
|
118
|
+
β should remove a node
|
|
119
|
+
β should remove itself
|
|
120
|
+
β should throw trying to remove root
|
|
121
|
+
#toCompressedJSON && Node#fromJSON
|
|
122
|
+
β should prepare a json for saving
|
|
123
|
+
β should build an index from a json file
|
|
124
|
+
#getChildFromPath
|
|
125
|
+
β should find a node starting from a path
|
|
126
|
+
β should find the last ancestor starting from a path
|
|
127
|
+
β should throw if the path is incorrect or does not exist
|
|
128
|
+
β should throw if looking for last ancestor and find existent node
|
|
129
|
+
#getPathToChild
|
|
130
|
+
β should find a node starting from a path
|
|
131
|
+
β should throw if child is not a Node
|
|
132
|
+
β should throw if child belows to another tree
|
|
133
|
+
#findDirectChildByName && #findChildById
|
|
134
|
+
β should find a direct child by name and by id
|
|
135
|
+
β should throw if looking for child of a file
|
|
136
|
+
β should throw if looking for child of a file
|
|
137
|
+
|
|
138
|
+
#Tree
|
|
139
|
+
#constructor
|
|
140
|
+
β should instantiate the Tree
|
|
141
|
+
β should throw if passing not an Secrez instance
|
|
142
|
+
#load
|
|
143
|
+
β should load an empty Tree
|
|
144
|
+
β should do nothing if already loaded
|
|
145
|
+
getEntryDetails
|
|
146
|
+
β should return the entry details of a node
|
|
147
|
+
#Fix
|
|
148
|
+
β should load a tree with tags (48ms)
|
|
149
|
+
β should simulate a conflict in the repo and recover lost entries when a valid tree exists (1162ms)
|
|
150
|
+
β should simulate a lost index in the repo and recover the entries when no valid tree is found (70ms)
|
|
151
|
+
Multi data sets
|
|
152
|
+
β should load the trees of two data sets
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
98 passing (3s)
|
|
171
156
|
|
|
172
157
|
---------------|---------|----------|---------|---------|-------------------------------------------
|
|
173
158
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
174
159
|
---------------|---------|----------|---------|---------|-------------------------------------------
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
[32;1m index.js [0m | [32;1m 100[0m | [32;1m 100[0m | [32;1m 100[0m | [32;1m 100[0m | [33;1m [0m
|
|
160
|
+
All files | 82.9 | 68.72 | 86.61 | 82.56 |
|
|
161
|
+
DataCache.js | 89.41 | 74.07 | 90.9 | 89.28 | 17-23,122-123,149
|
|
162
|
+
ExternalFs.js | 94.02 | 76.92 | 100 | 93.93 | 9,29,35,54
|
|
163
|
+
FileCipher.js | 88.63 | 73.33 | 100 | 88.63 | 8,52,80,85,94
|
|
164
|
+
FsUtils.js | 100 | 100 | 100 | 100 |
|
|
165
|
+
InternalFs.js | 86.99 | 72.63 | 88.46 | 86.88 | ...25,257,274,283,328,339,359,418-423,455
|
|
166
|
+
Messages.js | 100 | 100 | 100 | 100 |
|
|
167
|
+
Node.js | 66.1 | 54.81 | 78.72 | 65.31 | ...67,579-605,644-648,666,669,683-720,729
|
|
168
|
+
Tree.js | 89.91 | 74.09 | 86.48 | 89.63 | ...72,417-439,466,476,530,622,630,661-672
|
|
185
169
|
---------------|---------|----------|---------|---------|-------------------------------------------
|
|
186
|
-
|
|
170
|
+
|
|
171
|
+
> @secrez/fs@1.0.5 posttest /Users/francescosullo/Projects/Secrez/secrez/packages/fs
|
|
172
|
+
> nyc check-coverage --statements 80 --branches 65 --functions 80 --lines 80
|
|
173
|
+
|
package/package.json
CHANGED
|
@@ -1,45 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
"node": ">=10.0.0"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
2
|
+
"name": "@secrez/fs",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@secrez/core": "~1.0.5",
|
|
10
|
+
"@secrez/crypto": "~1.0.4",
|
|
11
|
+
"@secrez/utils": "~1.0.4",
|
|
12
|
+
"command-line-args": "^5.2.1",
|
|
13
|
+
"fs-extra": "^9.1.0",
|
|
14
|
+
"lodash": "^4.17.21"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@secrez/test-helpers": "~2.0.1",
|
|
18
|
+
"chai": "^4.5.0",
|
|
19
|
+
"cross-env": "^7.0.3",
|
|
20
|
+
"mocha": "^7.2.0",
|
|
21
|
+
"nyc": "^15.1.0"
|
|
22
|
+
},
|
|
23
|
+
"description": "The Secrez fs library.",
|
|
24
|
+
"main": "src/index.js",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/secrez/secrez.git"
|
|
28
|
+
},
|
|
29
|
+
"author": {
|
|
30
|
+
"name": "Francesco Sullo",
|
|
31
|
+
"email": "francesco@sullo.co"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=10.0.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"all-tests": "find test/** -name '*.test.js' | xargs ./node_modules/.bin/mocha -R spec",
|
|
38
|
+
"test-only": "cross-env NODE_ENV=test ./node_modules/.bin/mocha test/*.test.js test/**/*.test.js --exit",
|
|
39
|
+
"test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha test/*.test.js test/**/*.test.js --exit",
|
|
40
|
+
"posttest": "nyc check-coverage --statements 80 --branches 65 --functions 80 --lines 80"
|
|
41
|
+
}
|
|
42
|
+
}
|