@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 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
- * InternalFs
10
- * ExternalFs
11
- * FsUtils
12
- * Tree
13
- * Node
14
- * DataCache
15
- * FileCipher (starting from 1.0.3)
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
- __1.0.3__
24
- * Move `encryptFile` and `decryptFile` from ExternalFs to FileCipher
23
+ **1.0.3**
25
24
 
26
- __1.0.2__
27
- * Adds `encryptFile` and `decryptFile` to ExternalFs
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
- 3 passing (82ms)
33
-
34
- ---------------|---------|----------|---------|---------|----------------------------------------
35
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
36
- ---------------|---------|----------|---------|---------|----------------------------------------
37
- All files | 6.92 | 3.88 | 4.26 | 7.07 |
38
- DataCache.js | 8.24 | 1.85 | 9.09 | 8.33 | 11-150
39
- ExternalFs.js | 40.68 | 36.59 | 33.33 | 41.03 | 11-117,136,154,161,164,181,193,198,204
40
- FsUtils.js | 10.64 | 0 | 0 | 11.11 | 10-71
41
- InternalFs.js | 3.25 | 0 | 0 | 3.28 | 12-445
42
- Messages.js | 100 | 100 | 100 | 100 |
43
- Node.js | 2.01 | 0 | 0 | 2.05 | 12-731
44
- Tree.js | 1.91 | 0 | 0 | 1.97 | 11-647
45
- index.js | 100 | 100 | 100 | 100 |
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 test /Users/sullof/Projects/Personal/secrez/packages/fs
3
- > cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text ./node_modules/.bin/_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 (45ms)
149
-  1) should simulate a conflict in the repo and recover lost entries
150
-  βœ“ should simulate a lost index in the repo and recover the entries (77ms)
151
-  Multi data sets
152
-  βœ“ should load the trees of two data sets
153
-
154
-
155
-   97 passing (3s)
156
-  1 failing
157
-
158
-  1) #Tree
159
- #Fix
160
- should simulate a conflict in the repo and recover lost entries:
161
-
162
- AssertionError: expected 6 to equal 5
163
- + expected - actual
164
-
165
- -6
166
- +5
167
- 
168
- at Context.<anonymous> (test/Tree.test.js:330:14)
169
- 
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
- All files  |  91.05 |  79.52 |  92.25 |  90.94 |  
176
-  DataCache.js  |  89.41 |  74.07 |  90.91 |  89.29 | 18-24,123-124,150 
177
-  ExternalFs.js |  94.03 |  76.92 |  100 |  93.94 | 10,28,34,50 
178
-  FileCipher.js |  88.64 |  73.33 |  100 |  88.64 | 9,48,74,79,85 
179
-  FsUtils.js  |  100 |  100 |  100 |  100 |  
180
-  InternalFs.js |  86.99 |  72.63 |  88.46 |  86.89 | ...19,248,265,274,312,322,348,404-409,441
181
-  Messages.js  |  100 |  100 |  100 |  100 |  
182
-  Node.js  |  93.7 |  86.69 |  95.74 |  93.55 | ...77,495-501,561,567,582-586,645,691,699
183
-  Tree.js  |  90.19 |  74.1 |  86.49 |  90.14 | ...53,399-422,453,463,512,604,610,638-647
184
-  index.js  |  100 |  100 |  100 |  100 |  
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
-  ERROR  Test failed. See above for more details.
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
- "name": "@secrez/fs",
3
- "version": "1.0.3",
4
- "license": "MIT",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "scripts": {
9
- "lint": "eslint -c .eslintrc 'src/**/*.js' 'test/**/*.js'",
10
- "all-tests": "find test/** -name '*.test.js' | xargs ./node_modules/.bin/mocha -R spec",
11
- "test-only": "cross-env NODE_ENV=test ./node_modules/.bin/mocha test/*.test.js test/**/*.test.js --exit",
12
- "test": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text ./node_modules/.bin/_mocha test/*.test.js test/**/*.test.js --exit",
13
- "posttest": "nyc check-coverage --statements 85 --branches 80 --functions 85 --lines 85"
14
- },
15
- "dependencies": {
16
- "@secrez/core": "~1.0.3",
17
- "@secrez/crypto": "~1.0.1",
18
- "@secrez/utils": "~1.0.0",
19
- "command-line-args": "^5.1.1",
20
- "fs-extra": "^9.1.0",
21
- "lodash": "^4.17.15"
22
- },
23
- "devDependencies": {
24
- "@secrez/test-helpers": "~1.0.2",
25
- "chai": "^4.2.0",
26
- "cross-env": "^7.0.2",
27
- "eslint": "^6.8.0",
28
- "eslint-plugin-node": "^11.0.0",
29
- "mocha": "^7.1.1",
30
- "nyc": "^15.1.0"
31
- },
32
- "description": "The Secrez fs library.",
33
- "main": "src/index.js",
34
- "repository": {
35
- "type": "git",
36
- "url": "git+https://github.com/secrez/secrez.git"
37
- },
38
- "author": {
39
- "name": "Francesco Sullo",
40
- "email": "francesco@sullo.co"
41
- },
42
- "engines": {
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
+ }