not-node 5.0.22 → 5.1.2
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/.eslintrc.json +1 -1
- package/bin/not-deploy.js +52 -0
- package/index.js +21 -19
- package/package.json +1 -1
- package/src/app.js +61 -58
- package/src/auth/abstract.js +17 -19
- package/src/auth/const.js +8 -12
- package/src/auth/fields.js +143 -124
- package/src/auth/index.js +14 -14
- package/src/auth/roles.js +64 -63
- package/src/auth/routes.js +89 -54
- package/src/auth/rules.js +63 -63
- package/src/auth/session.js +60 -62
- package/src/bootstrap/form.js +13 -13
- package/src/bootstrap/logic.js +45 -41
- package/src/bootstrap/model.js +14 -17
- package/src/bootstrap/route.js +132 -53
- package/src/common.js +86 -79
- package/src/core/fields/ID.js +6 -6
- package/src/core/fields/__closed.js +3 -3
- package/src/core/fields/__latest.js +3 -3
- package/src/core/fields/__version.js +3 -3
- package/src/core/fields/__versions.js +3 -3
- package/src/core/fields/_id.js +6 -6
- package/src/core/fields/active.js +9 -9
- package/src/core/fields/codeName.js +9 -9
- package/src/core/fields/createdAt.js +17 -17
- package/src/core/fields/default.js +9 -9
- package/src/core/fields/description.js +11 -11
- package/src/core/fields/email.js +9 -9
- package/src/core/fields/enabled.js +9 -9
- package/src/core/fields/expiredAt.js +16 -16
- package/src/core/fields/height.js +11 -11
- package/src/core/fields/ip.js +10 -10
- package/src/core/fields/objectId.js +10 -10
- package/src/core/fields/owner.js +13 -13
- package/src/core/fields/ownerModel.js +11 -11
- package/src/core/fields/price.js +11 -11
- package/src/core/fields/requiredObject.js +10 -10
- package/src/core/fields/session.js +10 -10
- package/src/core/fields/size.js +11 -11
- package/src/core/fields/telephone.js +9 -9
- package/src/core/fields/title.js +15 -15
- package/src/core/fields/updatedAt.js +17 -17
- package/src/core/fields/userId.js +11 -12
- package/src/core/fields/uuid.js +11 -11
- package/src/core/fields/validators/email.js +6 -4
- package/src/core/fields/validators/owner.js +6 -4
- package/src/core/fields/width.js +11 -11
- package/src/domain.js +435 -431
- package/src/env.js +23 -23
- package/src/error.js +20 -23
- package/src/exceptions/db.js +23 -0
- package/src/exceptions/http.js +43 -0
- package/src/fields/index.js +106 -111
- package/src/form/fabric.js +19 -24
- package/src/form/form.js +195 -186
- package/src/form/index.js +2 -2
- package/src/generic/index.js +2 -0
- package/src/generic/logic.js +595 -0
- package/src/generic/route.js +76 -0
- package/src/init/additional.js +7 -7
- package/src/init/app.js +75 -68
- package/src/init/bodyparser.js +14 -14
- package/src/init/compression.js +6 -7
- package/src/init/core.js +12 -12
- package/src/init/cors.js +22 -24
- package/src/init/db/index.js +41 -43
- package/src/init/db/ioredis.js +28 -20
- package/src/init/db/mongoose.js +42 -32
- package/src/init/db/redis.js +59 -48
- package/src/init/env.js +44 -36
- package/src/init/express.js +18 -21
- package/src/init/fileupload.js +8 -10
- package/src/init/http.js +65 -47
- package/src/init/index.js +141 -148
- package/src/init/informer.js +7 -9
- package/src/init/methodoverride.js +4 -6
- package/src/init/middleware.js +23 -26
- package/src/init/modules.js +4 -4
- package/src/init/monitoring.js +8 -8
- package/src/init/rateLimiter.js +53 -45
- package/src/init/routes.js +67 -69
- package/src/init/security.js +37 -33
- package/src/init/sequence.js +111 -107
- package/src/init/sequence.standart.js +54 -56
- package/src/init/sessions/index.js +21 -21
- package/src/init/sessions/mongoose.js +49 -36
- package/src/init/sessions/redis.js +28 -27
- package/src/init/static.js +53 -40
- package/src/init/template.js +17 -17
- package/src/lib.js +230 -200
- package/src/manifest/batchRunner.js +26 -25
- package/src/manifest/initializator/forms.js +24 -24
- package/src/manifest/initializator/index.js +8 -10
- package/src/manifest/initializator/manifests.js +45 -42
- package/src/manifest/initializator/models.js +37 -34
- package/src/manifest/manifest.filter.js +130 -97
- package/src/manifest/manifest.js +103 -77
- package/src/manifest/module.js +350 -360
- package/src/manifest/registrator/fields.js +90 -85
- package/src/manifest/registrator/forms.js +47 -47
- package/src/manifest/registrator/index.js +14 -16
- package/src/manifest/registrator/locales.js +17 -16
- package/src/manifest/registrator/logics.js +66 -64
- package/src/manifest/registrator/models.js +64 -62
- package/src/manifest/registrator/routes.js +171 -132
- package/src/manifest/registrator/routes.ws.js +109 -103
- package/src/manifest/route.js +216 -161
- package/src/model/buildValidator.js +53 -42
- package/src/model/default.js +304 -286
- package/src/model/enrich.js +69 -61
- package/src/model/increment.js +124 -137
- package/src/model/proto.js +179 -148
- package/src/model/routine.js +85 -76
- package/src/model/utils.js +33 -0
- package/src/model/versioning.js +148 -130
- package/src/obsolete.js +12 -8
- package/src/parser.js +29 -22
- package/src/repos.js +29 -31
- package/src/rollup.js +75 -65
- package/src/shell.helpers.js +28 -28
- package/static.js +31 -0
- package/src/generic/router.js +0 -16
- package/src/manifest/module.models.js +0 -0
- package/src/manifest/module.status.js +0 -0
package/src/lib.js
CHANGED
|
@@ -1,237 +1,267 @@
|
|
|
1
1
|
/** @module Lib */
|
|
2
|
-
const Log = require(
|
|
3
|
-
const {objHas} = require(
|
|
4
|
-
const fs = require(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
const Log = require("not-log")(module, "lib");
|
|
3
|
+
const { objHas } = require("./common");
|
|
4
|
+
const fs = require("fs"),
|
|
5
|
+
os = require("os"),
|
|
6
|
+
fse = require("fs-extra"),
|
|
7
|
+
rmdir = require("rmdir"),
|
|
8
|
+
git = require("simple-git"),
|
|
9
|
+
ejs = require("ejs"),
|
|
10
|
+
path = require("path"),
|
|
11
|
+
nconf = require("nconf"),
|
|
12
|
+
repos = require("./repos.js"),
|
|
13
|
+
shell = require("./shell.helpers.js");
|
|
14
14
|
|
|
15
|
-
module.exports.getRepo = function(name){
|
|
16
|
-
|
|
15
|
+
module.exports.getRepo = function (name) {
|
|
16
|
+
return objHas(repos, name) ? repos[name] : false;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
module.exports.mkTmpDir = function(){
|
|
20
|
-
|
|
19
|
+
module.exports.mkTmpDir = function () {
|
|
20
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), "not-node-"));
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
module.exports.cloneRepo = function(repo, dir){
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
module.exports.cloneRepo = function (repo, dir) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
Log.log("Cloning ", repo.url, " into ", dir);
|
|
26
|
+
git()
|
|
27
|
+
.silent(false)
|
|
28
|
+
.clone(repo.url, dir, ["--depth", 1])
|
|
29
|
+
.exec((err) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
reject(err);
|
|
32
|
+
} else {
|
|
33
|
+
Log.log("done");
|
|
34
|
+
resolve();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
module.exports.clearRepo = async (repo, parentDir) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
Log.log("Clearing ", parentDir, " ...");
|
|
42
|
+
if (repo.clear) {
|
|
43
|
+
if (repo.clear.dirs || repo.clear.files) {
|
|
44
|
+
let counter =
|
|
45
|
+
(repo.clear.dirs ? repo.clear.dirs.length : 0) +
|
|
46
|
+
(repo.clear.files ? repo.clear.files.length : 0);
|
|
47
|
+
for (let dir of repo.clear.dirs) {
|
|
48
|
+
Log.log("removing ", dir);
|
|
49
|
+
rmdir(path.join(parentDir, dir), (err) => {
|
|
50
|
+
if (err) {
|
|
51
|
+
reject(err);
|
|
52
|
+
} else {
|
|
53
|
+
counter--;
|
|
54
|
+
if (!counter) {
|
|
55
|
+
Log.log("done");
|
|
56
|
+
resolve();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
53
60
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
for (let file of repo.clear.files) {
|
|
62
|
+
Log.log("removing ", file);
|
|
63
|
+
fs.exists(path.join(parentDir, file), (exists) => {
|
|
64
|
+
if (exists) {
|
|
65
|
+
fs.unlink(path.join(parentDir, file), (err) => {
|
|
66
|
+
if (err) {
|
|
67
|
+
reject(err);
|
|
68
|
+
} else {
|
|
69
|
+
counter--;
|
|
70
|
+
if (!counter) {
|
|
71
|
+
Log.log("done");
|
|
72
|
+
resolve();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
counter--;
|
|
78
|
+
if (!counter) {
|
|
79
|
+
Log.log("done");
|
|
80
|
+
resolve();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
77
84
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}else{
|
|
82
|
-
|
|
85
|
+
} else {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
return;
|
|
83
90
|
}
|
|
84
|
-
}else{
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
91
|
};
|
|
88
92
|
|
|
89
93
|
module.exports.moveCleanClone = async (repo, from, to) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
let counter = items.length;
|
|
95
|
-
for (let i = 0; i < items.length; i++) {
|
|
96
|
-
Log.log('moving', path.join(from, items[i]), ' >> ', path.join(to, items[i]));
|
|
97
|
-
await fse.move(path.join(from, items[i]), path.join(to, items[i]), { overwrite: true })
|
|
98
|
-
counter--;
|
|
99
|
-
if (counter === 0){
|
|
100
|
-
return;
|
|
94
|
+
const items = await fs.promises.readdir(from);
|
|
95
|
+
if (to.charAt(to.length - 1) === "/") {
|
|
96
|
+
to = to.substring(0, to.length - 1);
|
|
101
97
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
let cmds = repo.exec.after.map((item)=>{
|
|
113
|
-
return path.join(dir, item)+' '+ path.join(process.cwd(),dir);
|
|
98
|
+
let counter = items.length;
|
|
99
|
+
for (let i = 0; i < items.length; i++) {
|
|
100
|
+
Log.log(
|
|
101
|
+
"moving",
|
|
102
|
+
path.join(from, items[i]),
|
|
103
|
+
" >> ",
|
|
104
|
+
path.join(to, items[i])
|
|
105
|
+
);
|
|
106
|
+
await fse.move(path.join(from, items[i]), path.join(to, items[i]), {
|
|
107
|
+
overwrite: true,
|
|
114
108
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
reject(err);
|
|
120
|
-
}else{
|
|
121
|
-
resolve();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}else{
|
|
125
|
-
resolve();
|
|
126
|
-
}
|
|
127
|
-
}else{
|
|
128
|
-
resolve();
|
|
109
|
+
counter--;
|
|
110
|
+
if (counter === 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
129
113
|
}
|
|
130
|
-
});
|
|
131
114
|
};
|
|
132
115
|
|
|
116
|
+
module.exports.execShell = function (repo, dir) {
|
|
117
|
+
Log.log("exec shell");
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
// execute multiple commands in series
|
|
120
|
+
if (repo.exec) {
|
|
121
|
+
if (repo.exec.after && repo.exec.after.length) {
|
|
122
|
+
Log.log("exec commands", process.cwd());
|
|
123
|
+
let cmds = repo.exec.after.map((item) => {
|
|
124
|
+
return (
|
|
125
|
+
path.join(dir, item) +
|
|
126
|
+
" " +
|
|
127
|
+
path.join(process.cwd(), dir)
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
Log.log(cmds.join("\n"));
|
|
131
|
+
shell.series(cmds, function (err) {
|
|
132
|
+
if (err) {
|
|
133
|
+
Log.log(err);
|
|
134
|
+
reject(err);
|
|
135
|
+
} else {
|
|
136
|
+
resolve();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
resolve();
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
resolve();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
};
|
|
133
147
|
|
|
134
|
-
module.exports.cloneRoutine = function(repo, to){
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
module.exports.cloneRoutine = function (repo, to) {
|
|
149
|
+
return new Promise((resolve, reject) => {
|
|
150
|
+
let tmpDir = module.exports.mkTmpDir();
|
|
151
|
+
module.exports
|
|
152
|
+
.cloneRepo(repo, tmpDir)
|
|
153
|
+
.then(() => module.exports.clearRepo(repo, tmpDir))
|
|
154
|
+
.then(() => fse.ensureDir(path.join(to, repo.dir)))
|
|
155
|
+
.then(() =>
|
|
156
|
+
module.exports.moveCleanClone(
|
|
157
|
+
repo,
|
|
158
|
+
tmpDir,
|
|
159
|
+
path.join(to, repo.dir)
|
|
160
|
+
)
|
|
161
|
+
)
|
|
162
|
+
.then(() => module.exports.execShell(repo, path.join(to, repo.dir)))
|
|
163
|
+
.then(resolve)
|
|
164
|
+
.catch(reject);
|
|
165
|
+
});
|
|
145
166
|
};
|
|
146
167
|
|
|
147
|
-
module.exports.cloneParents = function(repo, to){
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
module.exports.cloneParents = function (repo, to) {
|
|
169
|
+
Log.log("Cloning parents...");
|
|
170
|
+
return new Promise((resolve, reject) => {
|
|
171
|
+
if (repos && repo && repo.extends && repo.extends.length > 0) {
|
|
172
|
+
let counter = repo.extends.length;
|
|
173
|
+
for (let dep of repo.extends) {
|
|
174
|
+
Log.log("Cloning parent", repos[dep].url);
|
|
175
|
+
module.exports
|
|
176
|
+
.cloneRoutine(repos[dep], to)
|
|
177
|
+
.then(() => {
|
|
178
|
+
counter--;
|
|
179
|
+
if (!counter) {
|
|
180
|
+
resolve();
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
.catch(reject);
|
|
159
184
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
resolve();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
185
|
+
} else {
|
|
186
|
+
resolve();
|
|
187
|
+
}
|
|
188
|
+
});
|
|
167
189
|
};
|
|
168
190
|
|
|
169
|
-
module.exports.rootCloneRoutine = function(repo, to){
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
191
|
+
module.exports.rootCloneRoutine = function (repo, to) {
|
|
192
|
+
Log.log("Clone root project", repo.url, "to", to);
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
194
|
+
let tmpDir = module.exports.mkTmpDir();
|
|
195
|
+
Log.log("tmp dir", tmpDir);
|
|
196
|
+
fse.ensureDir(path.join(to, repo.dir))
|
|
197
|
+
.then(() => fse.emptyDir(path.join(to, repo.dir)))
|
|
198
|
+
.then(() =>
|
|
199
|
+
module.exports.cloneParents(repo, path.join(to, repo.dir))
|
|
200
|
+
)
|
|
201
|
+
.then(() => module.exports.cloneRepo(repo, tmpDir))
|
|
202
|
+
.then(() =>
|
|
203
|
+
module.exports.moveCleanClone(
|
|
204
|
+
repo,
|
|
205
|
+
tmpDir,
|
|
206
|
+
path.join(to, repo.dir)
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
.then(() => module.exports.execShell(repo, path.join(to, repo.dir)))
|
|
210
|
+
.then(resolve)
|
|
211
|
+
.catch(reject);
|
|
212
|
+
});
|
|
183
213
|
};
|
|
184
214
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
module.exports.renderScript = function (input, options, dest) {
|
|
216
|
+
return new Promise((resolve, reject) => {
|
|
217
|
+
let js = ejs.renderFile(input, options, (err, res) => {
|
|
218
|
+
if (err) {
|
|
219
|
+
reject(err);
|
|
220
|
+
} else {
|
|
221
|
+
fs.writeFile(dest, res, (err) => {
|
|
222
|
+
if (err) {
|
|
223
|
+
reject(err);
|
|
224
|
+
} else {
|
|
225
|
+
resolve();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
195
229
|
});
|
|
196
|
-
}
|
|
197
230
|
});
|
|
198
|
-
});
|
|
199
231
|
};
|
|
200
232
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return nconf;
|
|
233
|
+
module.exports.getConfReader = function (pathToConfig) {
|
|
234
|
+
nconf.argv().env("__").file({
|
|
235
|
+
file: pathToConfig,
|
|
236
|
+
});
|
|
237
|
+
return nconf;
|
|
207
238
|
};
|
|
208
239
|
|
|
209
|
-
|
|
210
240
|
/**
|
|
211
|
-
* Joins many files in one
|
|
212
|
-
* @param {string} target result file path
|
|
213
|
-
* @param {array} sources list of source files
|
|
214
|
-
* @param {splitter} splitter file splitter
|
|
215
|
-
*/
|
|
216
|
-
module.exports.joinToFile = function(target, sources, splitter = "\n"){
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
241
|
+
* Joins many files in one
|
|
242
|
+
* @param {string} target result file path
|
|
243
|
+
* @param {array} sources list of source files
|
|
244
|
+
* @param {splitter} splitter file splitter
|
|
245
|
+
*/
|
|
246
|
+
module.exports.joinToFile = function (target, sources, splitter = "\n") {
|
|
247
|
+
return new Promise((resolve, reject) => {
|
|
248
|
+
try {
|
|
249
|
+
fse.ensureFileSync(target);
|
|
250
|
+
let data = [];
|
|
251
|
+
for (let t in sources) {
|
|
252
|
+
let file = fs.readFileSync(sources[t]);
|
|
253
|
+
if (process.NODE_ENV !== "production") {
|
|
254
|
+
data.push("<!-- start: " + sources[t] + " -->");
|
|
255
|
+
}
|
|
256
|
+
data.push(file);
|
|
257
|
+
if (process.NODE_ENV !== "production") {
|
|
258
|
+
data.push("<!-- end: " + sources[t] + " -->");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
fse.outputFileSync(target, data.join(splitter));
|
|
262
|
+
resolve();
|
|
263
|
+
} catch (e) {
|
|
264
|
+
resject(e);
|
|
229
265
|
}
|
|
230
|
-
|
|
231
|
-
fse.outputFileSync(target, data.join(splitter));
|
|
232
|
-
resolve();
|
|
233
|
-
}catch(e){
|
|
234
|
-
resject(e);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
266
|
+
});
|
|
237
267
|
};
|
|
@@ -2,32 +2,33 @@
|
|
|
2
2
|
* Search and register notModule resouces
|
|
3
3
|
* @class
|
|
4
4
|
**/
|
|
5
|
-
module.exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
module.exports = class BatchRunner {
|
|
6
|
+
#processors = [];
|
|
7
|
+
constructor(processors) {
|
|
8
|
+
this.setProcessors(processors);
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
setProcessors(list = []) {
|
|
12
|
+
this.#processors = [...list];
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Searching for content of module and registering it.
|
|
21
|
-
* @static
|
|
22
|
-
* @param {Object} input
|
|
23
|
-
* @param {notModule} input.nModule
|
|
24
|
-
* @return {boolean} true - executed, false - no paths
|
|
25
|
-
**/
|
|
26
|
-
exec({nModule}) {
|
|
27
|
-
if (!nModule.module.paths) {return false;}
|
|
28
|
-
//starting from simpliest forms and moving upwards
|
|
29
|
-
this.#processors.forEach(processor => new processor({nModule}));
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
15
|
+
resetProcessors() {
|
|
16
|
+
this.setProcessors();
|
|
17
|
+
}
|
|
32
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Searching for content of module and registering it.
|
|
21
|
+
* @static
|
|
22
|
+
* @param {Object} input
|
|
23
|
+
* @param {notModule} input.nModule
|
|
24
|
+
* @return {boolean} true - executed, false - no paths
|
|
25
|
+
**/
|
|
26
|
+
exec({ nModule }) {
|
|
27
|
+
if (!nModule.module.paths) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
//starting from simpliest forms and moving upwards
|
|
31
|
+
this.#processors.forEach((processor) => new processor({ nModule }));
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
33
34
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const {notError} = require(
|
|
2
|
-
const {
|
|
1
|
+
const { notError } = require("not-error");
|
|
2
|
+
const { error } = require("not-log")(module, "initializator");
|
|
3
3
|
|
|
4
|
-
module.exports = class notModuleInitializatorForms{
|
|
4
|
+
module.exports = class notModuleInitializatorForms {
|
|
5
|
+
static openFile = require;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.run({nModule, app: nModule.getApp()});
|
|
10
|
-
}
|
|
7
|
+
constructor({ nModule }) {
|
|
8
|
+
this.run({ nModule, app: nModule.getApp() });
|
|
9
|
+
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
run({ app, nModule }) {
|
|
12
|
+
const moduleName = nModule.getName();
|
|
13
|
+
for (let formName in nModule.getFormsConstructors()) {
|
|
14
|
+
try {
|
|
15
|
+
const formConstructor = nModule.getFormConstructor(formName);
|
|
16
|
+
nModule.setForm(formName, new formConstructor({ app }));
|
|
17
|
+
//log(`${moduleName}//${formName}`);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
error(
|
|
20
|
+
`Error while initialization of form: ${moduleName}//${formName}`
|
|
21
|
+
);
|
|
22
|
+
if (e instanceof notError) {
|
|
23
|
+
error(`name: ${e.options.field}, type: ${e.options.type}`);
|
|
24
|
+
} else {
|
|
25
|
+
error(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
|
-
}
|
|
27
29
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
30
|
};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
const BatchRunner = require(
|
|
1
|
+
const BatchRunner = require("../batchRunner.js");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Logic to find and register resources of notModule
|
|
5
5
|
* @module notModuleRegistrator
|
|
6
6
|
**/
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
notModuleInitializatorManifests = require('./manifests');
|
|
12
|
-
|
|
8
|
+
const notModuleInitializatorForms = require("./forms"),
|
|
9
|
+
notModuleInitializatorModels = require("./models"),
|
|
10
|
+
notModuleInitializatorManifests = require("./manifests");
|
|
13
11
|
|
|
14
12
|
const DEFAULT_INITIALIZATORS = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
notModuleInitializatorForms,
|
|
14
|
+
notModuleInitializatorModels,
|
|
15
|
+
notModuleInitializatorManifests,
|
|
18
16
|
];
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* Initialize registered notModule resouces
|
|
22
20
|
* @class
|
|
23
21
|
**/
|
|
24
|
-
module.exports
|
|
22
|
+
module.exports = new BatchRunner(DEFAULT_INITIALIZATORS);
|