nodefony 7.0.0-beta.2 → 7.0.0-beta.21
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/CHANGELOG.md +534 -8028
- package/README.md +33 -30
- package/autoloader.es6 +46 -48
- package/builder.es6 +66 -76
- package/cli/builder/bundles/bundle.js +57 -63
- package/cli/builder/bundles/controller.js +34 -38
- package/cli/builder/bundles/users-bundle/Command/fixtureTask.js +11 -12
- package/cli/builder/bundles/users-bundle/Command/usersCommand.js +23 -24
- package/cli/builder/bundles/users-bundle/Entity/mongoose/userEntity.js +25 -30
- package/cli/builder/bundles/users-bundle/Entity/sequelize/userEntity.js +42 -31
- package/cli/builder/bundles/users-bundle/Fixtures/users.js +24 -26
- package/cli/builder/bundles/users-bundle/Fixtures/usersFixtures.js +28 -29
- package/cli/builder/bundles/users-bundle/Resources/config/config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/routing.js +2 -2
- package/cli/builder/bundles/users-bundle/Resources/config/security.js +9 -8
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.dev.config.js +3 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.prod.config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +74 -75
- package/cli/builder/bundles/users-bundle/Resources/scss/awesome/font-awesome.config.js +9 -9
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/login.js +13 -13
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/users.js +14 -14
- package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +13 -15
- package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +29 -29
- package/cli/builder/bundles/users-bundle/controller/api/graphql/usertype.js +2 -2
- package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +34 -36
- package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +32 -36
- package/cli/builder/bundles/users-bundle/controller/loginController.js +30 -34
- package/cli/builder/bundles/users-bundle/controller/usersController.js +54 -60
- package/cli/builder/bundles/users-bundle/package.json +27 -25
- package/cli/builder/bundles/users-bundle/pnpm-lock.yaml +4262 -0
- package/cli/builder/bundles/users-bundle/readme.md +7 -7
- package/cli/builder/bundles/users-bundle/services/usersService.js +97 -102
- package/cli/builder/bundles/users-bundle/src/providers/mongoose/userProvider.js +6 -8
- package/cli/builder/bundles/users-bundle/src/providers/sequelize/userProvider.js +9 -10
- package/cli/builder/bundles/users-bundle/tests/loginTest.js +119 -70
- package/cli/builder/bundles/users-bundle/usersBundle.js +2 -3
- package/cli/builder/microService/microService.js +139 -141
- package/cli/builder/microService/skeletons/package.json +23 -22
- package/cli/builder/project/project.js +228 -181
- package/cli/builder/project/skeletons/README.md +33 -30
- package/cli/builder/project/skeletons/bin/dev-deploy.sh +5 -0
- package/cli/builder/project/skeletons/bin/prod-deploy.sh +3 -0
- package/cli/builder/project/skeletons/config/config.js.skeleton +1 -0
- package/cli/builder/project/skeletons/config/pm2.config.js.skeleton +41 -17
- package/cli/builder/project/skeletons/eslintignore.skeleton +15 -0
- package/cli/builder/project/skeletons/eslintrc.js.skeleton +97 -0
- package/cli/builder/project/skeletons/gitignore.skeleton +1 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.37.entity-user.js +137 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.38.entity-session.js +97 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.39.entity-requests.js +115 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.40.entity-jwts.js +97 -0
- package/cli/builder/project/skeletons/migrations/migrations.skeleton.js +0 -2
- package/cli/builder/project/skeletons/package.json.twig +70 -0
- package/cli/builder/react/reactBuilder.js +59 -65
- package/cli/builder/sandbox/sandBoxBuilder.js +132 -134
- package/cli/builder/skeletons/app/appKernel.js +120 -2
- package/cli/builder/skeletons/config/config.js +1 -1
- package/cli/builder/skeletons/config/nodefony/framework-bundle.js +2 -1
- package/cli/builder/skeletons/config/nodefony/http-bundle.js +1 -0
- package/cli/builder/skeletons/config/nodefony/mongoose-bundle.js +38 -12
- package/cli/builder/skeletons/config/nodefony/monitoring-bundle.js +21 -2
- package/cli/builder/skeletons/config/nodefony/sequelize-bundle.js +122 -13
- package/cli/builder/skeletons/package.json.twig +57 -0
- package/cli/builder/skeletons/unittest/testFile.js +44 -45
- package/cli/builder/vue/skeletons/vue.config.js +84 -10
- package/cli/builder/vue/vueBuilder.js +116 -114
- package/cli/generate/generate.es6 +38 -39
- package/cli/install/install.js +45 -58
- package/cli/sequelize/sequelize.js +50 -39
- package/cli/start.js +353 -347
- package/cli/tools/pm2.es6 +55 -57
- package/cli/tools/tools.es6 +36 -37
- package/cli.es6 +280 -228
- package/container.es6 +51 -59
- package/error.es6 +25 -27
- package/fileClass.es6 +53 -55
- package/finder/file.es6 +5 -4
- package/finder/fileResult.es6 +23 -22
- package/finder/finder2.es6 +46 -54
- package/finder.es6 +88 -97
- package/kernel/annotations/annotations.es6 +44 -46
- package/kernel/api/api.es6 +6 -8
- package/kernel/api/graphqlApi.es6 +21 -21
- package/kernel/api/jsonApi.es6 +40 -45
- package/kernel/api/openApi.es6 +9 -11
- package/kernel/api/schemas/openApiSchema.js +61 -32
- package/kernel/babylon.es6 +31 -38
- package/kernel/bundle.es6 +252 -220
- package/kernel/cliKernel.es6 +157 -170
- package/kernel/command.es6 +17 -20
- package/kernel/commands/nodefonyCommand.es6 +111 -58
- package/kernel/commands/tasks/bundlesTask.es6 +14 -19
- package/kernel/controllers/controller.es6 +167 -180
- package/kernel/fixture.es6 +4 -7
- package/kernel/injections/injections.es6 +97 -103
- package/kernel/kernel.es6 +476 -384
- package/kernel/kernelWatcher.es6 +64 -54
- package/kernel/orm/entity.es6 +10 -12
- package/kernel/orm/orm.es6 +68 -48
- package/kernel/reader.es6 +45 -47
- package/kernel/security/encoder.es6 +8 -6
- package/kernel/security/factories/factory.es6 +34 -37
- package/kernel/security/factories/passeportFactory.es6 +13 -14
- package/kernel/security/provider.es6 +11 -13
- package/kernel/security/providers/chainProvider.es6 +13 -28
- package/kernel/security/providers/memoryProvider.es6 +7 -11
- package/kernel/security/providers/providerManager.es6 +11 -14
- package/kernel/security/providers/userEntityProvider.es6 +7 -8
- package/kernel/security/role.es6 +3 -3
- package/kernel/security/secureArea.es6 +143 -149
- package/kernel/security/tokens/token.es6 +30 -32
- package/kernel/security/user.es6 +19 -19
- package/kernel/serviceRealTime.es6 +5 -7
- package/kernel/services/connectionsService.es6 +20 -22
- package/kernel/services/cron/cronService.es6 +14 -16
- package/kernel/task.es6 +20 -26
- package/kernel/templates.es6 +4 -5
- package/kernel/templating/twig.es6 +56 -47
- package/kernel/tests/cliTest.js +7 -11
- package/kernel/tests/containerTest.js +25 -37
- package/kernel/tests/kernelTest.js +9 -16
- package/nodefony.es6 +279 -256
- package/notificationsCenter.es6 +28 -20
- package/package.json +40 -40
- package/protocol.es6 +19 -21
- package/protocols/bayeux.es6 +35 -38
- package/protocols/jsonRpc/jsonrpc.es6 +12 -14
- package/result.es6 +11 -12
- package/service.es6 +62 -62
- package/syslog/pdu.es6 +99 -91
- package/syslog/syslog.es6 +101 -102
- package/watcher.es6 +21 -20
- package/cli/builder/project/skeletons/jshintignore.skeleton +0 -1
- package/cli/builder/project/skeletons/jshintrc.skeleton +0 -60
- package/cli/builder/project/skeletons/package.json.skeleton +0 -52
- package/cli/builder/skeletons/package.json +0 -61
package/finder/fileResult.es6
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
//const _ = require("lodash");
|
|
1
|
+
// const _ = require("lodash");
|
|
2
2
|
class FileResult extends nodefony.Result {
|
|
3
|
-
constructor(res) {
|
|
4
|
-
if(typeof
|
|
3
|
+
constructor (res) {
|
|
4
|
+
if (typeof res === "number") {
|
|
5
5
|
super();
|
|
6
|
-
}else{
|
|
6
|
+
} else {
|
|
7
7
|
super(res);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
toString() {
|
|
12
|
-
let txt =
|
|
11
|
+
toString () {
|
|
12
|
+
let txt = "";
|
|
13
13
|
for (let index = 0; index < this.length; index++) {
|
|
14
|
-
|
|
14
|
+
const info = this[index];
|
|
15
15
|
txt += `${info.name}\n`;
|
|
16
16
|
}
|
|
17
17
|
return txt;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
toJson (json = []) {
|
|
20
21
|
try {
|
|
21
22
|
for (let index = 0; index < this.length; index++) {
|
|
22
|
-
|
|
23
|
+
const info = this[index];
|
|
23
24
|
switch (info.type) {
|
|
24
25
|
case "File":
|
|
25
26
|
json.push(info.toJson());
|
|
26
27
|
break;
|
|
27
28
|
case "symbolicLink":
|
|
28
29
|
case "Directory":
|
|
29
|
-
|
|
30
|
+
const dir = info.toJson();
|
|
30
31
|
if (info.children) {
|
|
31
32
|
dir.children = info.children.toJson();
|
|
32
33
|
}
|
|
@@ -40,15 +41,15 @@ class FileResult extends nodefony.Result {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
uniq() {
|
|
44
|
+
uniq () {
|
|
44
45
|
return this;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
find(ele, result = new FileResult()) {
|
|
48
|
+
find (ele, result = new FileResult()) {
|
|
48
49
|
try {
|
|
49
50
|
for (let index = 0; index < this.length; index++) {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const info = this[index];
|
|
52
|
+
const match = info.matchName(ele);
|
|
52
53
|
if (match) {
|
|
53
54
|
result.push(info);
|
|
54
55
|
}
|
|
@@ -60,10 +61,10 @@ class FileResult extends nodefony.Result {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
getDirectories(result = new FileResult()) {
|
|
64
|
+
getDirectories (result = new FileResult()) {
|
|
64
65
|
try {
|
|
65
66
|
for (let index = 0; index < this.length; index++) {
|
|
66
|
-
|
|
67
|
+
const info = this[index];
|
|
67
68
|
switch (info.type) {
|
|
68
69
|
case "Directory":
|
|
69
70
|
result.push(info);
|
|
@@ -80,10 +81,10 @@ class FileResult extends nodefony.Result {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
getFiles(result = new FileResult()) {
|
|
84
|
+
getFiles (result = new FileResult()) {
|
|
84
85
|
try {
|
|
85
86
|
for (let index = 0; index < this.length; index++) {
|
|
86
|
-
|
|
87
|
+
const info = this[index];
|
|
87
88
|
switch (info.type) {
|
|
88
89
|
case "File":
|
|
89
90
|
result.push(info);
|
|
@@ -100,8 +101,8 @@ class FileResult extends nodefony.Result {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
sortByName(result = new FileResult()) {
|
|
104
|
-
|
|
104
|
+
sortByName (result = new FileResult()) {
|
|
105
|
+
const res = this.sort((a, b) => {
|
|
105
106
|
if (a.name.toString() > b.name.toString()) {
|
|
106
107
|
return 1;
|
|
107
108
|
}
|
|
@@ -116,8 +117,8 @@ class FileResult extends nodefony.Result {
|
|
|
116
117
|
return this;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
sortByType(result = new FileResult()) {
|
|
120
|
-
|
|
120
|
+
sortByType (result = new FileResult()) {
|
|
121
|
+
const res = this.sort((a, b) => {
|
|
121
122
|
if (a.type.toString() > b.type.toString()) {
|
|
122
123
|
return 1;
|
|
123
124
|
}
|
package/finder/finder2.es6
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* CLASS Result
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
const fsPromises = require(
|
|
5
|
+
const fsPromises = require("fs").promises;
|
|
6
6
|
const defaultSettings = {
|
|
7
7
|
recurse: false,
|
|
8
8
|
depth: 10,
|
|
@@ -16,7 +16,7 @@ const defaultSettings = {
|
|
|
16
16
|
|
|
17
17
|
const checkExclude = function (info, options) {
|
|
18
18
|
let match = null;
|
|
19
|
-
|
|
19
|
+
const test = options.exclude || options.excludeDir || options.excludeFile;
|
|
20
20
|
if (!test) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
@@ -48,11 +48,11 @@ const checkExclude = function (info, options) {
|
|
|
48
48
|
const checkMatch = function (info, options, result) {
|
|
49
49
|
let match = false;
|
|
50
50
|
let rec = false;
|
|
51
|
-
|
|
51
|
+
const test = options.matchFile || options.matchDIr || options.match;
|
|
52
52
|
if (!test) {
|
|
53
53
|
result.push(info);
|
|
54
54
|
this.totals[info.type]++;
|
|
55
|
-
this.fire(
|
|
55
|
+
this.fire(`on${info.type}`, info, this);
|
|
56
56
|
return true;
|
|
57
57
|
}
|
|
58
58
|
if (options.matchDIr) {
|
|
@@ -74,8 +74,8 @@ const checkMatch = function (info, options, result) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
if (options.match) {
|
|
77
|
-
|
|
78
|
-
//console.log("match ", info.name, res)
|
|
77
|
+
const res = info.matchName(options.match);
|
|
78
|
+
// console.log("match ", info.name, res)
|
|
79
79
|
if (res) {
|
|
80
80
|
match = true;
|
|
81
81
|
} else {
|
|
@@ -83,26 +83,25 @@ const checkMatch = function (info, options, result) {
|
|
|
83
83
|
rec = info.type;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
//state match
|
|
86
|
+
// state match
|
|
87
87
|
if (match) {
|
|
88
88
|
result.push(info);
|
|
89
89
|
this.totals[info.type]++;
|
|
90
|
-
this.fire(
|
|
90
|
+
this.fire(`on${info.type}`, info, this);
|
|
91
91
|
return true;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
92
|
+
}
|
|
93
|
+
switch (rec) {
|
|
94
|
+
// false match
|
|
95
|
+
case "Directory":
|
|
96
|
+
case "symbolicLink":
|
|
97
|
+
result.push(info);
|
|
98
|
+
this.totals[info.type]++;
|
|
99
|
+
this.fire(`on${info.type}`, info, this);
|
|
100
|
+
return true;
|
|
101
|
+
default:
|
|
102
|
+
// false file
|
|
103
|
+
// console.log("bypass ", info.name)
|
|
104
|
+
return false;
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
107
|
|
|
@@ -118,22 +117,16 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
118
117
|
try {
|
|
119
118
|
if (file.type !== "symbolicLink") {
|
|
120
119
|
res = await fsPromises.readdir(file.path, {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.catch(e =>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//console.log("symbolicLink First", file.name)
|
|
130
|
-
res = await fsPromises.readlink(file.path)
|
|
131
|
-
.catch((e) => {
|
|
132
|
-
return reject(e);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
120
|
+
encoding: "utf8",
|
|
121
|
+
withFileTypes: false
|
|
122
|
+
})
|
|
123
|
+
.catch((e) => reject(e));
|
|
124
|
+
} else if (options.followSymLink) {
|
|
125
|
+
// console.log("symbolicLink First", file.name)
|
|
126
|
+
res = await fsPromises.readlink(file.path)
|
|
127
|
+
.catch((e) => reject(e));
|
|
135
128
|
}
|
|
136
|
-
//console.log(res)
|
|
129
|
+
// console.log(res)
|
|
137
130
|
if (res && res.length) {
|
|
138
131
|
for (let i = 0; i < res.length; i++) {
|
|
139
132
|
const ret = path.resolve(file.path, res[i]);
|
|
@@ -146,7 +139,7 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
146
139
|
}
|
|
147
140
|
}
|
|
148
141
|
if (checkExclude(info, options)) {
|
|
149
|
-
//console.log("EXCLUDEEEEE", info.name)
|
|
142
|
+
// console.log("EXCLUDEEEEE", info.name)
|
|
150
143
|
continue;
|
|
151
144
|
}
|
|
152
145
|
let symLink = null;
|
|
@@ -160,7 +153,7 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
160
153
|
}
|
|
161
154
|
}
|
|
162
155
|
const match = checkMatch.call(this, info, options, result);
|
|
163
|
-
//console.log("match state", !match, info.name, info.type)
|
|
156
|
+
// console.log("match state", !match, info.name, info.type)
|
|
164
157
|
if (!match) {
|
|
165
158
|
continue;
|
|
166
159
|
}
|
|
@@ -169,7 +162,7 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
169
162
|
this.totals.hidden++;
|
|
170
163
|
this.fire("onHidden", info, this);
|
|
171
164
|
}
|
|
172
|
-
//console.log("PASSSS ", info.name, info.type)
|
|
165
|
+
// console.log("PASSSS ", info.name, info.type)
|
|
173
166
|
if (info.type === "File") {
|
|
174
167
|
continue;
|
|
175
168
|
}
|
|
@@ -177,16 +170,16 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
177
170
|
if (!options.recurse) {
|
|
178
171
|
continue;
|
|
179
172
|
}
|
|
180
|
-
//console.log("RECCCCCC", info.type, info.name)
|
|
173
|
+
// console.log("RECCCCCC", info.type, info.name)
|
|
181
174
|
switch (info.type) {
|
|
182
175
|
case "Directory":
|
|
183
|
-
//info.children = await parser.call(this, info, undefined, options, depth - 1, info);
|
|
176
|
+
// info.children = await parser.call(this, info, undefined, options, depth - 1, info);
|
|
184
177
|
await parser.call(this, info, undefined, options, depth - 1, info);
|
|
185
178
|
break;
|
|
186
179
|
case "symbolicLink":
|
|
187
180
|
if (symLink) {
|
|
188
181
|
if (symLink.isDirectory()) {
|
|
189
|
-
//info.children = await parser.call(this, symLink, undefined, options, depth - 1, info);
|
|
182
|
+
// info.children = await parser.call(this, symLink, undefined, options, depth - 1, info);
|
|
190
183
|
await parser.call(this, symLink, undefined, options, depth - 1, info);
|
|
191
184
|
}
|
|
192
185
|
}
|
|
@@ -194,7 +187,7 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
194
187
|
}
|
|
195
188
|
}
|
|
196
189
|
}
|
|
197
|
-
//console.log("resolve ", file.name, result.length)
|
|
190
|
+
// console.log("resolve ", file.name, result.length)
|
|
198
191
|
return resolve(result);
|
|
199
192
|
} catch (e) {
|
|
200
193
|
this.fire("onError", e);
|
|
@@ -204,8 +197,7 @@ const parser = function (file, result = new nodefony.FileResult(), options = {},
|
|
|
204
197
|
};
|
|
205
198
|
|
|
206
199
|
class Finder extends nodefony.Events {
|
|
207
|
-
|
|
208
|
-
constructor(settings) {
|
|
200
|
+
constructor (settings) {
|
|
209
201
|
super(settings);
|
|
210
202
|
this.settings = nodefony.extend({}, defaultSettings, settings);
|
|
211
203
|
this.totals = {
|
|
@@ -220,16 +212,16 @@ class Finder extends nodefony.Events {
|
|
|
220
212
|
};
|
|
221
213
|
}
|
|
222
214
|
|
|
223
|
-
clean() {
|
|
215
|
+
clean () {
|
|
224
216
|
this.removeAllListeners();
|
|
225
|
-
for (
|
|
217
|
+
for (const total in this.totals) {
|
|
226
218
|
this.totals[total] = 0;
|
|
227
219
|
}
|
|
228
220
|
}
|
|
229
221
|
|
|
230
|
-
ckeckPath(Path) {
|
|
222
|
+
ckeckPath (Path) {
|
|
231
223
|
const type = nodefony.typeOf(Path);
|
|
232
|
-
|
|
224
|
+
const result = new nodefony.FileResult();
|
|
233
225
|
switch (true) {
|
|
234
226
|
case type === "string":
|
|
235
227
|
try {
|
|
@@ -261,14 +253,14 @@ class Finder extends nodefony.Events {
|
|
|
261
253
|
}
|
|
262
254
|
}
|
|
263
255
|
|
|
264
|
-
async in(Path, settings = {}) {
|
|
256
|
+
async in (Path, settings = {}) {
|
|
265
257
|
let result = null;
|
|
266
258
|
try {
|
|
267
259
|
result = this.ckeckPath(Path);
|
|
268
260
|
this.settingsToListen(settings);
|
|
269
|
-
|
|
270
|
-
for await (
|
|
271
|
-
await parser.call(this, res, undefined, options, options.depth, res)
|
|
261
|
+
const options = nodefony.extend({}, this.settings, settings);
|
|
262
|
+
for await (const res of result) {
|
|
263
|
+
await parser.call(this, res, undefined, options, options.depth, res);
|
|
272
264
|
}
|
|
273
265
|
} catch (e) {
|
|
274
266
|
this.fire("onError", e);
|
package/finder.es6
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class jsonTree extends nodefony.fileClass {
|
|
2
|
-
constructor(path, parent) {
|
|
2
|
+
constructor (path, parent) {
|
|
3
3
|
super(path);
|
|
4
4
|
this.parent = parent;
|
|
5
5
|
if (this.parent !== null && this.parent.children) {
|
|
@@ -25,8 +25,7 @@ const findExist = function (tab, file) {
|
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
class Result {
|
|
28
|
-
|
|
29
|
-
constructor(res) {
|
|
28
|
+
constructor (res) {
|
|
30
29
|
if (res && nodefony.typeOf(res) === "array") {
|
|
31
30
|
this.files = res;
|
|
32
31
|
} else {
|
|
@@ -35,24 +34,24 @@ class Result {
|
|
|
35
34
|
this.json = {};
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
push(file) {
|
|
37
|
+
push (file) {
|
|
39
38
|
this.files.push(file);
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
length() {
|
|
41
|
+
length () {
|
|
43
42
|
return this.files.length;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
slice(offset, limit) {
|
|
45
|
+
slice (offset, limit) {
|
|
47
46
|
return new Result(Array.prototype.slice.call(this.files, offset, limit));
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
sort(callback) {
|
|
49
|
+
sort (callback) {
|
|
51
50
|
return new Result(Array.prototype.sort.call(this.files, callback));
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
sortByName() {
|
|
55
|
-
|
|
53
|
+
sortByName () {
|
|
54
|
+
const res = this.files.sort((a, b) => {
|
|
56
55
|
if (a.name.toString() > b.name.toString()) {
|
|
57
56
|
return 1;
|
|
58
57
|
}
|
|
@@ -67,8 +66,8 @@ class Result {
|
|
|
67
66
|
return this;
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
sortByType() {
|
|
71
|
-
|
|
69
|
+
sortByType () {
|
|
70
|
+
const res = this.files.sort((a, b) => {
|
|
72
71
|
if (a.type.toString() > b.type.toString()) {
|
|
73
72
|
return 1;
|
|
74
73
|
}
|
|
@@ -83,7 +82,7 @@ class Result {
|
|
|
83
82
|
return this;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
findByNode(nodeName, tab, Path) {
|
|
85
|
+
findByNode (nodeName, tab, Path) {
|
|
87
86
|
let i = null;
|
|
88
87
|
if (!Path) {
|
|
89
88
|
Path = [];
|
|
@@ -113,8 +112,8 @@ class Result {
|
|
|
113
112
|
return new Result(tab);
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
getDirectories() {
|
|
117
|
-
|
|
115
|
+
getDirectories () {
|
|
116
|
+
const tab = [];
|
|
118
117
|
for (let i = 0; i < this.files.length; i++) {
|
|
119
118
|
if (this.files[i].type === "Directory") {
|
|
120
119
|
tab.push(this.files[i]);
|
|
@@ -123,16 +122,16 @@ class Result {
|
|
|
123
122
|
return new Result(tab);
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
getFiles() {
|
|
127
|
-
|
|
125
|
+
getFiles () {
|
|
126
|
+
const tab = [];
|
|
128
127
|
for (let i = 0; i < this.files.length; i++) {
|
|
129
128
|
switch (this.files[i].type) {
|
|
130
129
|
case "File":
|
|
131
130
|
tab.push(this.files[i]);
|
|
132
131
|
break;
|
|
133
132
|
case "symbolicLink":
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
const path = fs.readlinkSync(this.files[i].path);
|
|
134
|
+
const file = `${this.files[i].dirName}/${path}`;
|
|
136
135
|
if (fs.lstatSync(file).isFile()) {
|
|
137
136
|
tab.push(this.files[i]);
|
|
138
137
|
}
|
|
@@ -142,36 +141,32 @@ class Result {
|
|
|
142
141
|
return new Result(tab);
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
getFile(name, casse) {
|
|
144
|
+
getFile (name, casse) {
|
|
146
145
|
let reg = null;
|
|
147
146
|
for (let i = 0; i < this.files.length; i++) {
|
|
148
147
|
switch (this.files[i].type) {
|
|
149
148
|
case "File":
|
|
150
149
|
if (casse) {
|
|
151
|
-
reg = new RegExp(
|
|
150
|
+
reg = new RegExp(`^${name}$`, "i");
|
|
152
151
|
if (reg.test(this.files[i].name)) {
|
|
153
152
|
return this.files[i];
|
|
154
153
|
}
|
|
155
|
-
} else {
|
|
156
|
-
|
|
157
|
-
return this.files[i];
|
|
158
|
-
}
|
|
154
|
+
} else if (this.files[i].name === name) {
|
|
155
|
+
return this.files[i];
|
|
159
156
|
}
|
|
160
157
|
break;
|
|
161
158
|
case "symbolicLink":
|
|
162
159
|
try {
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
const path = fs.readlinkSync(this.files[i].path);
|
|
161
|
+
const file = `${this.files[i].dirName}/${path}`;
|
|
165
162
|
if (fs.lstatSync(file).isFile()) {
|
|
166
163
|
if (casse) {
|
|
167
|
-
reg = new RegExp(
|
|
164
|
+
reg = new RegExp(`^${name}$`, "i");
|
|
168
165
|
if (reg.test(this.files[i].name)) {
|
|
169
166
|
return this.files[i];
|
|
170
167
|
}
|
|
171
|
-
} else {
|
|
172
|
-
|
|
173
|
-
return this.files[i];
|
|
174
|
-
}
|
|
168
|
+
} else if (this.files[i].name === name) {
|
|
169
|
+
return this.files[i];
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
172
|
} catch (e) {
|
|
@@ -183,14 +178,14 @@ class Result {
|
|
|
183
178
|
return null;
|
|
184
179
|
}
|
|
185
180
|
|
|
186
|
-
forEach(callback) {
|
|
181
|
+
forEach (callback) {
|
|
187
182
|
return this.files.forEach(callback);
|
|
188
183
|
}
|
|
189
184
|
|
|
190
|
-
match(reg) {
|
|
191
|
-
|
|
185
|
+
match (reg) {
|
|
186
|
+
const tab = [];
|
|
192
187
|
for (let i = 0; i < this.files.length; i++) {
|
|
193
|
-
|
|
188
|
+
const res = this.files[i].matchName(reg);
|
|
194
189
|
if (res) {
|
|
195
190
|
tab.push(this.files[i]);
|
|
196
191
|
}
|
|
@@ -208,12 +203,11 @@ const checkMatch = function (file, settings) {
|
|
|
208
203
|
if (settings.match) {
|
|
209
204
|
if (file.matchName(settings.match)) {
|
|
210
205
|
return true;
|
|
211
|
-
} else {
|
|
212
|
-
if (file.matchType(settings.match)) {
|
|
213
|
-
return settings.match;
|
|
214
|
-
}
|
|
215
|
-
return false;
|
|
216
206
|
}
|
|
207
|
+
if (file.matchType(settings.match)) {
|
|
208
|
+
return settings.match;
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
217
211
|
}
|
|
218
212
|
return true;
|
|
219
213
|
};
|
|
@@ -252,17 +246,17 @@ const findStatic = function (file, result, depth, settings, parent) {
|
|
|
252
246
|
}
|
|
253
247
|
|
|
254
248
|
if (res && res.length) {
|
|
255
|
-
|
|
249
|
+
const ret = regSlash.exec(file.path);
|
|
256
250
|
let filePath = null;
|
|
257
251
|
if (ret) {
|
|
258
|
-
filePath = ret[1]
|
|
252
|
+
filePath = `${ret[1]}/`;
|
|
259
253
|
} else {
|
|
260
|
-
filePath = file.path
|
|
254
|
+
filePath = `${file.path}/`;
|
|
261
255
|
}
|
|
262
256
|
for (let i = 0; i < res.length; i++) {
|
|
263
257
|
let match = true;
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
const File = filePath + res[i];
|
|
259
|
+
const info = new this.wrapper(File, parent);
|
|
266
260
|
if (!settings.seeHidden) {
|
|
267
261
|
if (checkHidden.call(this, info, settings)) {
|
|
268
262
|
if (parent && parent.children) {
|
|
@@ -284,11 +278,9 @@ const findStatic = function (file, result, depth, settings, parent) {
|
|
|
284
278
|
}
|
|
285
279
|
if (match) {
|
|
286
280
|
result.push(info);
|
|
287
|
-
this.notificationsCenter.fire(
|
|
288
|
-
} else {
|
|
289
|
-
|
|
290
|
-
parent.children.pop();
|
|
291
|
-
}
|
|
281
|
+
this.notificationsCenter.fire(`on${info.type}`, info, this);
|
|
282
|
+
} else if (parent && parent.children) {
|
|
283
|
+
parent.children.pop();
|
|
292
284
|
}
|
|
293
285
|
switch (info.type) {
|
|
294
286
|
case "Directory":
|
|
@@ -299,7 +291,7 @@ const findStatic = function (file, result, depth, settings, parent) {
|
|
|
299
291
|
break;
|
|
300
292
|
case "symbolicLink":
|
|
301
293
|
if (settings.followSymLink && depth - 1 !== 0) {
|
|
302
|
-
|
|
294
|
+
const obj = new this.wrapper(info.path, info);
|
|
303
295
|
if (obj.isDirectory()) {
|
|
304
296
|
arguments.callee.call(this, obj, result, settings.depth, settings, parent);
|
|
305
297
|
}
|
|
@@ -312,8 +304,8 @@ const findStatic = function (file, result, depth, settings, parent) {
|
|
|
312
304
|
} catch (e) {
|
|
313
305
|
this.notificationsCenter.fire("onError", e);
|
|
314
306
|
this.errorParse.push(e);
|
|
315
|
-
//console.log(e);
|
|
316
|
-
//this.notificationsCenter.fire("onFinish",e,null);
|
|
307
|
+
// console.log(e);
|
|
308
|
+
// this.notificationsCenter.fire("onFinish",e,null);
|
|
317
309
|
throw e;
|
|
318
310
|
}
|
|
319
311
|
};
|
|
@@ -324,8 +316,8 @@ const defaultSettings = {
|
|
|
324
316
|
sync: true,
|
|
325
317
|
recurse: true,
|
|
326
318
|
depth: -1,
|
|
327
|
-
//onFinish: null,
|
|
328
|
-
//onFile: null,
|
|
319
|
+
// onFinish: null,
|
|
320
|
+
// onFile: null,
|
|
329
321
|
seeHidden: false,
|
|
330
322
|
match: null,
|
|
331
323
|
exclude: null,
|
|
@@ -336,70 +328,69 @@ const defaultSettings = {
|
|
|
336
328
|
|
|
337
329
|
const regSlash = /^(.*)\/$/g;
|
|
338
330
|
class Finder {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
331
|
+
constructor (settings) {
|
|
332
|
+
this.path = [];
|
|
333
|
+
this.errorParse = [];
|
|
334
|
+
this.settings = nodefony.extend({}, defaultSettings, settings);
|
|
335
|
+
if (this.settings.path) {
|
|
336
|
+
this.result = this.find();
|
|
337
|
+
} else {
|
|
338
|
+
this.tree = this.settings.json;
|
|
339
|
+
if (this.tree) {
|
|
340
|
+
this.wrapper = jsonTree;
|
|
346
341
|
} else {
|
|
347
|
-
this.
|
|
348
|
-
if (this.tree) {
|
|
349
|
-
this.wrapper = jsonTree;
|
|
350
|
-
} else {
|
|
351
|
-
this.wrapper = nodefony.fileClass;
|
|
352
|
-
}
|
|
342
|
+
this.wrapper = nodefony.fileClass;
|
|
353
343
|
}
|
|
354
344
|
}
|
|
345
|
+
}
|
|
355
346
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return this;
|
|
363
|
-
} catch (e) {
|
|
364
|
-
throw e;
|
|
365
|
-
}
|
|
366
|
-
break;
|
|
367
|
-
case this.typePath === "array":
|
|
368
|
-
for (let i = 0; i < Path.length; i++) {
|
|
369
|
-
try {
|
|
370
|
-
this.path.push(new this.wrapper(Path[i], null));
|
|
371
|
-
} catch (e) {
|
|
372
|
-
throw e;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
347
|
+
in (Path) {
|
|
348
|
+
this.typePath = nodefony.typeOf(Path);
|
|
349
|
+
switch (true) {
|
|
350
|
+
case this.typePath === "string":
|
|
351
|
+
try {
|
|
352
|
+
this.path.push(new this.wrapper(Path, null));
|
|
375
353
|
return this;
|
|
376
|
-
|
|
354
|
+
} catch (e) {
|
|
355
|
+
throw e;
|
|
356
|
+
}
|
|
357
|
+
break;
|
|
358
|
+
case this.typePath === "array":
|
|
359
|
+
for (let i = 0; i < Path.length; i++) {
|
|
377
360
|
try {
|
|
378
|
-
this.path.push(new this.wrapper(Path
|
|
379
|
-
return this;
|
|
361
|
+
this.path.push(new this.wrapper(Path[i], null));
|
|
380
362
|
} catch (e) {
|
|
381
363
|
throw e;
|
|
382
364
|
}
|
|
383
|
-
break;
|
|
384
|
-
//default:
|
|
385
|
-
// throw new Error(`Finder bad path type`);
|
|
386
365
|
}
|
|
366
|
+
return this;
|
|
367
|
+
case Path instanceof nodefony.fileClass:
|
|
368
|
+
try {
|
|
369
|
+
this.path.push(new this.wrapper(Path.path, null));
|
|
370
|
+
return this;
|
|
371
|
+
} catch (e) {
|
|
372
|
+
throw e;
|
|
373
|
+
}
|
|
374
|
+
break;
|
|
375
|
+
// default:
|
|
376
|
+
// throw new Error(`Finder bad path type`);
|
|
387
377
|
}
|
|
378
|
+
}
|
|
388
379
|
|
|
389
|
-
files() {
|
|
380
|
+
files () {
|
|
390
381
|
return this.find({
|
|
391
382
|
match: "File"
|
|
392
383
|
});
|
|
393
384
|
}
|
|
394
385
|
|
|
395
|
-
directories() {
|
|
386
|
+
directories () {
|
|
396
387
|
return this.find({
|
|
397
388
|
match: "Directory"
|
|
398
389
|
});
|
|
399
390
|
}
|
|
400
391
|
|
|
401
|
-
find(settings) {
|
|
402
|
-
|
|
392
|
+
find (settings) {
|
|
393
|
+
const result = new Result();
|
|
403
394
|
let extend = null;
|
|
404
395
|
if (!settings) {
|
|
405
396
|
extend = this.settings;
|