not-node 6.2.21 → 6.2.23
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/package.json +1 -1
- package/src/generic/logic.js +4 -4
- package/src/manifest/registrator/fields.js +13 -3
- package/src/manifest/registrator/routes.js +37 -31
- package/test/module/routes.js +306 -264
- package/bin/not-deploy.js +0 -52
- package/bin/not-mongo.sh +0 -1
- package/static.js +0 -31
- package/static2.js +0 -24
package/package.json
CHANGED
package/src/generic/logic.js
CHANGED
|
@@ -245,7 +245,7 @@ module.exports = ({
|
|
|
245
245
|
if (shouldOwn) {
|
|
246
246
|
query[ownerFieldName] = activeUser?._id;
|
|
247
247
|
}
|
|
248
|
-
let populate = getPopulate(action, {
|
|
248
|
+
let populate = await getPopulate(action, {
|
|
249
249
|
targetId,
|
|
250
250
|
activeUser,
|
|
251
251
|
ip,
|
|
@@ -335,7 +335,7 @@ module.exports = ({
|
|
|
335
335
|
if (shouldOwn) {
|
|
336
336
|
query[ownerFieldName] = activeUser?._id;
|
|
337
337
|
}
|
|
338
|
-
let populate = getPopulate(action, {
|
|
338
|
+
let populate = await getPopulate(action, {
|
|
339
339
|
targetID,
|
|
340
340
|
activeUser,
|
|
341
341
|
ip,
|
|
@@ -664,7 +664,7 @@ module.exports = ({
|
|
|
664
664
|
root
|
|
665
665
|
);
|
|
666
666
|
const { skip, size, sorter, filter, search } = query;
|
|
667
|
-
let populate = getPopulate(action, {
|
|
667
|
+
let populate = await getPopulate(action, {
|
|
668
668
|
activeUser,
|
|
669
669
|
ip,
|
|
670
670
|
});
|
|
@@ -728,7 +728,7 @@ module.exports = ({
|
|
|
728
728
|
root
|
|
729
729
|
);
|
|
730
730
|
const { skip, size, sorter, filter } = query;
|
|
731
|
-
let populate = getPopulate(action, {
|
|
731
|
+
let populate = await getPopulate(action, {
|
|
732
732
|
activeUser,
|
|
733
733
|
ip,
|
|
734
734
|
});
|
|
@@ -49,6 +49,16 @@ module.exports = class notModuleRegistratorFields {
|
|
|
49
49
|
log(`${MODULE_NAME}//${name} with ${fieldValidatorsCount} validators`);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
findValidatorsFile(name, fromPath, possible_extensions = [".js", ".cjs"]) {
|
|
53
|
+
for (let ext of possible_extensions) {
|
|
54
|
+
const validatorName = path.join(fromPath, "validators", name + ext);
|
|
55
|
+
if (tryFile(validatorName)) {
|
|
56
|
+
return validatorName;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
/**
|
|
53
63
|
*
|
|
54
64
|
**/
|
|
@@ -57,9 +67,9 @@ module.exports = class notModuleRegistratorFields {
|
|
|
57
67
|
return;
|
|
58
68
|
}
|
|
59
69
|
//load validators
|
|
60
|
-
const validatorName =
|
|
61
|
-
if (!
|
|
62
|
-
return
|
|
70
|
+
const validatorName = this.findValidatorsFile(name, fromPath);
|
|
71
|
+
if (!validatorName) {
|
|
72
|
+
return;
|
|
63
73
|
}
|
|
64
74
|
const validators = notModuleRegistratorFields.openFile(validatorName);
|
|
65
75
|
//inject into field.model
|
|
@@ -12,21 +12,21 @@ const notModuleRegistratorRoutesWS = require("./routes.ws");
|
|
|
12
12
|
* @constant
|
|
13
13
|
* @type {string}
|
|
14
14
|
*/
|
|
15
|
-
const
|
|
15
|
+
const DEFAULT_MANIFEST_FILE_ENDINGS = [".manifest.js", ".manifest.cjs"];
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Routes collection files ending
|
|
19
19
|
* @constant
|
|
20
20
|
* @type {string}
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
22
|
+
const DEFAULT_ROUTES_FILE_ENDINGS = [".js", ".cjs"];
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* WS End-points collection files ending
|
|
26
26
|
* @constant
|
|
27
27
|
* @type {string}
|
|
28
28
|
*/
|
|
29
|
-
const
|
|
29
|
+
const DEFAULT_WS_ROUTES_FILE_ENDINGS = [".ws.js", ".ws.cjs"];
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* List of methods to be binded from notApp to routes and WS end-points
|
|
@@ -78,10 +78,23 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
78
78
|
);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
getFileBasename(file, possible_extensions = []) {
|
|
82
|
+
for (let ext of possible_extensions) {
|
|
83
|
+
if (file.indexOf(ext) !== -1) {
|
|
84
|
+
return file.substr(0, file.indexOf(ext));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
81
90
|
findOne({ nModule, srcDir, file }) {
|
|
82
91
|
try {
|
|
83
92
|
//если имя похоже на название манифеста
|
|
84
|
-
|
|
93
|
+
const routeBasename = this.getFileBasename(
|
|
94
|
+
file,
|
|
95
|
+
DEFAULT_MANIFEST_FILE_ENDINGS
|
|
96
|
+
);
|
|
97
|
+
if (!routeBasename) {
|
|
85
98
|
return false;
|
|
86
99
|
}
|
|
87
100
|
const routeManifest =
|
|
@@ -93,10 +106,6 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
93
106
|
if (!routeManifest) {
|
|
94
107
|
return false;
|
|
95
108
|
}
|
|
96
|
-
const routeBasename = file.substr(
|
|
97
|
-
0,
|
|
98
|
-
file.indexOf(DEFAULT_MANIFEST_FILE_ENDING)
|
|
99
|
-
);
|
|
100
109
|
//ищем end-points
|
|
101
110
|
const route = notModuleRegistratorRoutes.tryRouteFile({
|
|
102
111
|
srcDir,
|
|
@@ -124,20 +133,18 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
static tryRouteFile({ srcDir, routeBasename }) {
|
|
127
|
-
|
|
128
|
-
srcDir,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
route
|
|
136
|
+
for (let ext of DEFAULT_ROUTES_FILE_ENDINGS) {
|
|
137
|
+
const routePath = path.join(srcDir, routeBasename + ext);
|
|
138
|
+
if (tryFile(routePath)) {
|
|
139
|
+
const route = notModuleRegistratorRoutes.openFile(routePath);
|
|
140
|
+
route.filename = routePath;
|
|
141
|
+
if (!route.thisRouteName) {
|
|
142
|
+
route.thisRouteName = routeBasename;
|
|
143
|
+
}
|
|
144
|
+
return route;
|
|
136
145
|
}
|
|
137
|
-
return route;
|
|
138
|
-
} else {
|
|
139
|
-
return false;
|
|
140
146
|
}
|
|
147
|
+
return false;
|
|
141
148
|
}
|
|
142
149
|
|
|
143
150
|
static tryRouteManifestFile({ srcDir, file }) {
|
|
@@ -150,19 +157,18 @@ module.exports = class notModuleRegistratorRoutes {
|
|
|
150
157
|
}
|
|
151
158
|
|
|
152
159
|
static tryWSRouteFile({ srcDir, routeBasename }) {
|
|
153
|
-
|
|
154
|
-
srcDir,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
for (let ext of DEFAULT_WS_ROUTES_FILE_ENDINGS) {
|
|
161
|
+
const routeWSPath = path.join(srcDir, routeBasename + ext);
|
|
162
|
+
if (tryFile(routeWSPath)) {
|
|
163
|
+
const wsRoute =
|
|
164
|
+
notModuleRegistratorRoutes.openFile(routeWSPath);
|
|
165
|
+
if (!wsRoute.thisRouteName) {
|
|
166
|
+
wsRoute.thisRouteName = routeBasename;
|
|
167
|
+
}
|
|
168
|
+
return wsRoute;
|
|
161
169
|
}
|
|
162
|
-
return wsRoute;
|
|
163
|
-
} else {
|
|
164
|
-
return false;
|
|
165
170
|
}
|
|
171
|
+
return false;
|
|
166
172
|
}
|
|
167
173
|
|
|
168
174
|
registerManifestAndRoutes({
|
package/test/module/routes.js
CHANGED
|
@@ -1,288 +1,330 @@
|
|
|
1
|
-
const path = require(
|
|
2
|
-
const notModuleRegistratorRoutes = require(
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const notModuleRegistratorRoutes = require("../../src/manifest/registrator/routes");
|
|
3
3
|
|
|
4
|
-
module.exports = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
expect(pathTo).to.be.equal(testPath);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('run', () => {
|
|
25
|
-
it('path to routes is not defined', function() {
|
|
26
|
-
const ctx = {
|
|
27
|
-
findAll(){}
|
|
28
|
-
};
|
|
29
|
-
const param = {
|
|
30
|
-
nModule:{
|
|
31
|
-
module:{ paths:{} }
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const res = notModuleRegistratorRoutes.prototype.run.call(ctx, param);
|
|
35
|
-
expect(res).to.be.false;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('paths to routes is defined', function() {
|
|
39
|
-
const ctx = {
|
|
40
|
-
findAll(){}
|
|
41
|
-
};
|
|
42
|
-
const param = {
|
|
43
|
-
nModule:{
|
|
44
|
-
module:{ paths:{routes: 'path_to_routes'} }
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const res = notModuleRegistratorRoutes.prototype.run.call(ctx, param);
|
|
48
|
-
expect(res).to.be.true;
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
describe('tryRouteFile', function() {
|
|
54
|
-
it('route file doesnt exists', function() {
|
|
55
|
-
const res = notModuleRegistratorRoutes.tryRouteFile({
|
|
56
|
-
srcDir: routesPath,
|
|
57
|
-
routeBasename: 'jingle'
|
|
4
|
+
module.exports = ({ expect }) => {
|
|
5
|
+
describe("notModuleRegistratorRoutes", () => {
|
|
6
|
+
const routesPath = path.join(__dirname, "../testies/module/routes");
|
|
7
|
+
describe("getPath", () => {
|
|
8
|
+
it("module paths(routes)", function () {
|
|
9
|
+
const testPath = "path_to_routes";
|
|
10
|
+
const ctx = {
|
|
11
|
+
module: {
|
|
12
|
+
paths: {
|
|
13
|
+
routes: testPath,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const pathTo = notModuleRegistratorRoutes.getPath(ctx);
|
|
18
|
+
expect(pathTo).to.be.equal(testPath);
|
|
19
|
+
});
|
|
58
20
|
});
|
|
59
|
-
expect(res).to.be.false;
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('tryRouteManifestFile', function() {
|
|
64
|
-
it('route file doesnt exists', function() {
|
|
65
|
-
const res = notModuleRegistratorRoutes.tryRouteManifestFile({
|
|
66
|
-
srcDir: routesPath,
|
|
67
|
-
file: 'jingle'
|
|
68
|
-
});
|
|
69
|
-
expect(res).to.be.false;
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
21
|
|
|
22
|
+
describe("run", () => {
|
|
23
|
+
it("path to routes is not defined", function () {
|
|
24
|
+
const ctx = {
|
|
25
|
+
findAll() {},
|
|
26
|
+
};
|
|
27
|
+
const param = {
|
|
28
|
+
nModule: {
|
|
29
|
+
module: { paths: {} },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const res = notModuleRegistratorRoutes.prototype.run.call(
|
|
33
|
+
ctx,
|
|
34
|
+
param
|
|
35
|
+
);
|
|
36
|
+
expect(res).to.be.false;
|
|
37
|
+
});
|
|
73
38
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
39
|
+
it("paths to routes is defined", function () {
|
|
40
|
+
const ctx = {
|
|
41
|
+
findAll() {},
|
|
42
|
+
};
|
|
43
|
+
const param = {
|
|
44
|
+
nModule: {
|
|
45
|
+
module: { paths: { routes: "path_to_routes" } },
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const res = notModuleRegistratorRoutes.prototype.run.call(
|
|
49
|
+
ctx,
|
|
50
|
+
param
|
|
51
|
+
);
|
|
52
|
+
expect(res).to.be.true;
|
|
53
|
+
});
|
|
80
54
|
});
|
|
81
|
-
expect(res).to.be.false;
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
55
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const res = notModuleRegistratorRoutes.prototype.findOne.call(ctx, param);
|
|
95
|
-
expect(res).to.be.false;
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('route and ws-route files doesnt exists', function() {
|
|
99
|
-
const ctx = {};
|
|
100
|
-
const param = {
|
|
101
|
-
nModule: {},
|
|
102
|
-
srcDir: routesPath,
|
|
103
|
-
file: 'jingle.manifest.js'
|
|
104
|
-
};
|
|
105
|
-
const res = notModuleRegistratorRoutes.prototype.findOne.call(ctx, param);
|
|
106
|
-
expect(res).to.be.false;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('route - exists; wsRoute - !exists;', function() {
|
|
110
|
-
const ctx = {};
|
|
111
|
-
const param = {
|
|
112
|
-
nModule: {},
|
|
113
|
-
srcDir: routesPath,
|
|
114
|
-
file: 'icon.manifest.js'
|
|
115
|
-
};
|
|
116
|
-
const res = notModuleRegistratorRoutes.prototype.findOne.call(ctx, param);
|
|
117
|
-
expect(res).to.be.false;
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('route - !exists; wsRoute - exists;', function() {
|
|
121
|
-
const ctx = {
|
|
122
|
-
registerManifestAndRoutes({wsRoute}){
|
|
123
|
-
expect(wsRoute).to.be.ok;
|
|
124
|
-
expect(wsRoute.clients).to.have.keys(['main']);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
const param = {
|
|
128
|
-
nModule: {},
|
|
129
|
-
srcDir: routesPath,
|
|
130
|
-
file: 'logo.manifest.js'
|
|
131
|
-
};
|
|
132
|
-
const res = notModuleRegistratorRoutes.prototype.findOne.call(ctx, param);
|
|
133
|
-
expect(res).to.be.true;
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
describe('registerManifestAndRoutes', function() {
|
|
140
|
-
it('route not exists, ws end-points exists', function() {
|
|
141
|
-
let i = 0;
|
|
142
|
-
notModuleRegistratorRoutes.prototype.registerManifestAndRoutes.call({
|
|
143
|
-
registerRoute() {
|
|
144
|
-
i++;
|
|
145
|
-
},
|
|
146
|
-
registerWSRoute() {
|
|
147
|
-
i++
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
nModule:{
|
|
151
|
-
setManifest(){},
|
|
152
|
-
},
|
|
153
|
-
route: false,
|
|
154
|
-
wsRoute: true
|
|
56
|
+
describe("tryRouteFile", function () {
|
|
57
|
+
it("route file doesnt exists", function () {
|
|
58
|
+
const res = notModuleRegistratorRoutes.tryRouteFile({
|
|
59
|
+
srcDir: routesPath,
|
|
60
|
+
routeBasename: "jingle",
|
|
61
|
+
});
|
|
62
|
+
expect(res).to.be.false;
|
|
63
|
+
});
|
|
155
64
|
});
|
|
156
|
-
expect(i).to.be.equal(1);
|
|
157
|
-
});
|
|
158
65
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
}, {
|
|
169
|
-
nModule:{
|
|
170
|
-
setManifest(){},
|
|
171
|
-
},
|
|
172
|
-
route: {thisRouteName: 'asdf'},
|
|
173
|
-
wsRoute: false
|
|
66
|
+
describe("tryRouteManifestFile", function () {
|
|
67
|
+
it("route file doesnt exists", function () {
|
|
68
|
+
const res = notModuleRegistratorRoutes.tryRouteManifestFile({
|
|
69
|
+
srcDir: routesPath,
|
|
70
|
+
file: "jingle",
|
|
71
|
+
});
|
|
72
|
+
expect(res).to.be.false;
|
|
73
|
+
});
|
|
174
74
|
});
|
|
175
|
-
expect(i).to.be.equal(1);
|
|
176
|
-
});
|
|
177
75
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
nModule:{
|
|
189
|
-
setManifest(){},
|
|
190
|
-
},
|
|
191
|
-
route: {thisRouteName: 'asdf'},
|
|
192
|
-
wsRoute: {thisRouteName: 'asdf.ws'}
|
|
76
|
+
describe("tryWSRouteFile", function () {
|
|
77
|
+
it("route file doesnt exists", function () {
|
|
78
|
+
const res = notModuleRegistratorRoutes.tryWSRouteFile({
|
|
79
|
+
srcDir: routesPath,
|
|
80
|
+
routeBasename: "jingle",
|
|
81
|
+
});
|
|
82
|
+
expect(res).to.be.false;
|
|
83
|
+
});
|
|
193
84
|
});
|
|
194
|
-
expect(i).to.be.equal(2);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
85
|
|
|
86
|
+
describe("findOne", function () {
|
|
87
|
+
it("route manifest file doesnt exists", function () {
|
|
88
|
+
const ctx = {};
|
|
89
|
+
const param = {
|
|
90
|
+
nModule: {},
|
|
91
|
+
srcDir: routesPath,
|
|
92
|
+
file: "mangle.manifest.js",
|
|
93
|
+
};
|
|
94
|
+
const res = notModuleRegistratorRoutes.prototype.findOne.call(
|
|
95
|
+
ctx,
|
|
96
|
+
param
|
|
97
|
+
);
|
|
98
|
+
expect(res).to.be.false;
|
|
99
|
+
});
|
|
198
100
|
|
|
101
|
+
it("route and ws-route files doesnt exists", function () {
|
|
102
|
+
const ctx = {};
|
|
103
|
+
const param = {
|
|
104
|
+
nModule: {},
|
|
105
|
+
srcDir: routesPath,
|
|
106
|
+
file: "jingle.manifest.js",
|
|
107
|
+
};
|
|
108
|
+
const res = notModuleRegistratorRoutes.prototype.findOne.call(
|
|
109
|
+
ctx,
|
|
110
|
+
param
|
|
111
|
+
);
|
|
112
|
+
expect(res).to.be.false;
|
|
113
|
+
});
|
|
199
114
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
expect(params[0]).to.be.equal(route.thisRouteName);
|
|
214
|
-
expect(params[1]).to.be.deep.equal(route);
|
|
215
|
-
},
|
|
216
|
-
appIsSet(){return true;},
|
|
217
|
-
getApp(){
|
|
218
|
-
return {
|
|
219
|
-
getModel(){},
|
|
220
|
-
getModelFile(){},
|
|
221
|
-
getModelSchema(){},
|
|
222
|
-
getLogic(){},
|
|
223
|
-
getLogicFile(){},
|
|
224
|
-
getModule(){},
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
notModuleRegistratorRoutes.prototype.registerRoute.call(ctx, param);
|
|
230
|
-
expect(typeof route.getLogic).to.be.equal('function');
|
|
231
|
-
expect(typeof route.getLogicFile).to.be.equal('function');
|
|
232
|
-
expect(typeof route.getModel).to.be.equal('function');
|
|
233
|
-
expect(typeof route.getModelFile).to.be.equal('function');
|
|
234
|
-
expect(typeof route.getModelSchema).to.be.equal('function');
|
|
235
|
-
expect(typeof route.getModule).to.be.equal('function');
|
|
236
|
-
expect(typeof route.log.log).to.be.equal('function');
|
|
237
|
-
expect(typeof route.log.error).to.be.equal('function');
|
|
238
|
-
expect(typeof route.log.debug).to.be.equal('function');
|
|
115
|
+
it("route - exists; wsRoute - !exists;", function () {
|
|
116
|
+
const ctx = {};
|
|
117
|
+
const param = {
|
|
118
|
+
nModule: {},
|
|
119
|
+
srcDir: routesPath,
|
|
120
|
+
file: "icon.manifest.js",
|
|
121
|
+
};
|
|
122
|
+
const res = notModuleRegistratorRoutes.prototype.findOne.call(
|
|
123
|
+
ctx,
|
|
124
|
+
param
|
|
125
|
+
);
|
|
126
|
+
expect(res).to.be.false;
|
|
127
|
+
});
|
|
239
128
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
129
|
+
it("route - !exists; wsRoute - exists;", function () {
|
|
130
|
+
const ctx = {
|
|
131
|
+
getFileBasename() {
|
|
132
|
+
return "logo";
|
|
133
|
+
},
|
|
134
|
+
registerManifestAndRoutes({ wsRoute }) {
|
|
135
|
+
expect(wsRoute).to.be.ok;
|
|
136
|
+
console.log(Object.keys(wsRoute.clients));
|
|
137
|
+
expect(wsRoute.clients).to.have.keys(["main"]);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
const param = {
|
|
141
|
+
nModule: {},
|
|
142
|
+
srcDir: routesPath,
|
|
143
|
+
file: "logo.manifest.js",
|
|
144
|
+
};
|
|
145
|
+
const res = notModuleRegistratorRoutes.prototype.findOne.call(
|
|
146
|
+
ctx,
|
|
147
|
+
param
|
|
148
|
+
);
|
|
149
|
+
expect(res).to.be.true;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
243
152
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
getLogicFile(){},
|
|
267
|
-
getModule(){},
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
notModuleRegistratorRoutes.prototype.registerRoute.call(ctx, param);
|
|
153
|
+
describe("registerManifestAndRoutes", function () {
|
|
154
|
+
it("route not exists, ws end-points exists", function () {
|
|
155
|
+
let i = 0;
|
|
156
|
+
notModuleRegistratorRoutes.prototype.registerManifestAndRoutes.call(
|
|
157
|
+
{
|
|
158
|
+
registerRoute() {
|
|
159
|
+
i++;
|
|
160
|
+
},
|
|
161
|
+
registerWSRoute() {
|
|
162
|
+
i++;
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
nModule: {
|
|
167
|
+
setManifest() {},
|
|
168
|
+
},
|
|
169
|
+
route: false,
|
|
170
|
+
wsRoute: true,
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
expect(i).to.be.equal(1);
|
|
174
|
+
});
|
|
273
175
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
176
|
+
it("route exists, ws end-points not exists", function () {
|
|
177
|
+
let i = 0;
|
|
178
|
+
notModuleRegistratorRoutes.prototype.registerManifestAndRoutes.call(
|
|
179
|
+
{
|
|
180
|
+
registerRoute() {
|
|
181
|
+
i++;
|
|
182
|
+
},
|
|
183
|
+
registerWSRoute() {
|
|
184
|
+
i++;
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
nModule: {
|
|
189
|
+
setManifest() {},
|
|
190
|
+
},
|
|
191
|
+
route: { thisRouteName: "asdf" },
|
|
192
|
+
wsRoute: false,
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
expect(i).to.be.equal(1);
|
|
196
|
+
});
|
|
277
197
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
198
|
+
it("route exists, ws end-points exists", function () {
|
|
199
|
+
let i = 0;
|
|
200
|
+
notModuleRegistratorRoutes.prototype.registerManifestAndRoutes.call(
|
|
201
|
+
{
|
|
202
|
+
registerRoute() {
|
|
203
|
+
i++;
|
|
204
|
+
},
|
|
205
|
+
registerWSRoute() {
|
|
206
|
+
i++;
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
nModule: {
|
|
211
|
+
setManifest() {},
|
|
212
|
+
},
|
|
213
|
+
route: { thisRouteName: "asdf" },
|
|
214
|
+
wsRoute: { thisRouteName: "asdf.ws" },
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
expect(i).to.be.equal(2);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
282
220
|
|
|
221
|
+
describe("registerRoute", function () {
|
|
222
|
+
it("notApp exists", function () {
|
|
223
|
+
const route = {
|
|
224
|
+
thisRouteName: "filename",
|
|
225
|
+
filename: "filename",
|
|
226
|
+
};
|
|
227
|
+
const ctx = {};
|
|
228
|
+
const param = {
|
|
229
|
+
route,
|
|
230
|
+
routeName: "",
|
|
231
|
+
fromPath: "",
|
|
232
|
+
nModule: {
|
|
233
|
+
setRoute(...params) {
|
|
234
|
+
expect(params[0]).to.be.equal(route.thisRouteName);
|
|
235
|
+
expect(params[1]).to.be.deep.equal(route);
|
|
236
|
+
},
|
|
237
|
+
appIsSet() {
|
|
238
|
+
return true;
|
|
239
|
+
},
|
|
240
|
+
getApp() {
|
|
241
|
+
return {
|
|
242
|
+
getModel() {},
|
|
243
|
+
getModelFile() {},
|
|
244
|
+
getModelSchema() {},
|
|
245
|
+
getLogic() {},
|
|
246
|
+
getLogicFile() {},
|
|
247
|
+
getModule() {},
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
notModuleRegistratorRoutes.prototype.registerRoute.call(
|
|
253
|
+
ctx,
|
|
254
|
+
param
|
|
255
|
+
);
|
|
256
|
+
expect(typeof route.getLogic).to.be.equal("function");
|
|
257
|
+
expect(typeof route.getLogicFile).to.be.equal("function");
|
|
258
|
+
expect(typeof route.getModel).to.be.equal("function");
|
|
259
|
+
expect(typeof route.getModelFile).to.be.equal("function");
|
|
260
|
+
expect(typeof route.getModelSchema).to.be.equal("function");
|
|
261
|
+
expect(typeof route.getModule).to.be.equal("function");
|
|
262
|
+
expect(typeof route.log.log).to.be.equal("function");
|
|
263
|
+
expect(typeof route.log.error).to.be.equal("function");
|
|
264
|
+
expect(typeof route.log.debug).to.be.equal("function");
|
|
283
265
|
|
|
266
|
+
expect(route).to.have.keys([
|
|
267
|
+
"getThisModule",
|
|
268
|
+
"thisRouteName",
|
|
269
|
+
"filename",
|
|
270
|
+
"log",
|
|
271
|
+
"getModel",
|
|
272
|
+
"getModelFile",
|
|
273
|
+
"getModelSchema",
|
|
274
|
+
"getLogic",
|
|
275
|
+
"getLogicFile",
|
|
276
|
+
"getModule",
|
|
277
|
+
]);
|
|
278
|
+
expect(route.getThisModule()).to.be.deep.equal(param.nModule);
|
|
279
|
+
});
|
|
284
280
|
|
|
285
|
-
|
|
281
|
+
it("notApp doesnt exists", function () {
|
|
282
|
+
const route = {
|
|
283
|
+
thisRouteName: "filename",
|
|
284
|
+
filename: "filename",
|
|
285
|
+
};
|
|
286
|
+
const ctx = {};
|
|
287
|
+
const param = {
|
|
288
|
+
route,
|
|
289
|
+
routeName: "",
|
|
290
|
+
fromPath: "",
|
|
291
|
+
nModule: {
|
|
292
|
+
setRoute(...params) {
|
|
293
|
+
expect(params[0]).to.be.equal(route.thisRouteName);
|
|
294
|
+
expect(params[1]).to.be.deep.equal(route);
|
|
295
|
+
},
|
|
296
|
+
appIsSet() {
|
|
297
|
+
return false;
|
|
298
|
+
},
|
|
299
|
+
getApp() {
|
|
300
|
+
return {
|
|
301
|
+
getModel() {},
|
|
302
|
+
getModelFile() {},
|
|
303
|
+
getModelSchema() {},
|
|
304
|
+
getLogic() {},
|
|
305
|
+
getLogicFile() {},
|
|
306
|
+
getModule() {},
|
|
307
|
+
};
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
notModuleRegistratorRoutes.prototype.registerRoute.call(
|
|
312
|
+
ctx,
|
|
313
|
+
param
|
|
314
|
+
);
|
|
286
315
|
|
|
316
|
+
expect(typeof route.log.log).to.be.equal("function");
|
|
317
|
+
expect(typeof route.log.error).to.be.equal("function");
|
|
318
|
+
expect(typeof route.log.debug).to.be.equal("function");
|
|
287
319
|
|
|
320
|
+
expect(route).to.have.keys([
|
|
321
|
+
"getThisModule",
|
|
322
|
+
"thisRouteName",
|
|
323
|
+
"filename",
|
|
324
|
+
"log",
|
|
325
|
+
]);
|
|
326
|
+
expect(route.getThisModule()).to.be.deep.equal(param.nModule);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
288
330
|
};
|
package/bin/not-deploy.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
#!/bin/bash
|
|
4
|
-
cwd
|
|
5
|
-
echo 'deploying to production'
|
|
6
|
-
cd reporter
|
|
7
|
-
npm run production
|
|
8
|
-
cd ../
|
|
9
|
-
echo 'syncing data'
|
|
10
|
-
rsync -av --progress --exclude-from='./deploy/.exclude' reporter cypher@appmon.ru:/var/server/appmon.ru/
|
|
11
|
-
rsync -av --progress deploy/production.json cypher@appmon.ru:/var/server/appmon.ru/deploy/production.json
|
|
12
|
-
ssh cypher@appmon.ru "cd /var/server/appmon.ru/reporter && npm i"
|
|
13
|
-
ssh cypher@appmon.ru "cd /var/server/appmon.ru && pm2 startOrRestart deploy/production.json"
|
|
14
|
-
exit 0;
|
|
15
|
-
|
|
16
|
-
read config
|
|
17
|
-
cycle through remote locations
|
|
18
|
-
deploy as selected method in config say
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
deploy:{
|
|
22
|
-
stage:{},
|
|
23
|
-
production:{
|
|
24
|
-
src:{
|
|
25
|
-
type: "fs", //fs, git
|
|
26
|
-
location: "/var/work/project", //path to dir or url of repo
|
|
27
|
-
include: [], //optional, files to not copy
|
|
28
|
-
exclude: [], //optional, files to not copy
|
|
29
|
-
//will be executed localy
|
|
30
|
-
before-setup: "", //optional, shell cmd
|
|
31
|
-
after-setup: "", //optional, shell cmd
|
|
32
|
-
before: "", //optional, shell cmd
|
|
33
|
-
after: "", //optional, shell cmd
|
|
34
|
-
secret: "./production.env" //optional
|
|
35
|
-
},
|
|
36
|
-
dest:{
|
|
37
|
-
username: "deploy-master-3000", //
|
|
38
|
-
server: ["username@server", "10.0.1.12"], //
|
|
39
|
-
path: "/path/on/server", //
|
|
40
|
-
//will be executed on remote side
|
|
41
|
-
before-setup: "", //optional, shell cmd
|
|
42
|
-
after-setup: "", //optional, shell cmd
|
|
43
|
-
before: "", //optional, shell cmd
|
|
44
|
-
after: "", //optional, shell cmd
|
|
45
|
-
secret: "/path/on/server/where/secret_should_be_copied" //optional
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
**/
|
package/bin/not-mongo.sh
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
package/static.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const generate = ({ NAME }) => {
|
|
2
|
-
return class {
|
|
3
|
-
static run(prefix) {
|
|
4
|
-
return prefix + NAME;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
static faster(prefix) {
|
|
8
|
-
return this.run(prefix) + " is faster";
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const proto1 = generate({ NAME: "sonic" });
|
|
14
|
-
const proto2 = generate({ NAME: "lorde" });
|
|
15
|
-
const proto3 = generate({ NAME: "vanish" });
|
|
16
|
-
|
|
17
|
-
class res1 extends proto1 {
|
|
18
|
-
static faster(prefix) {
|
|
19
|
-
return this.run(prefix) + " is even faster";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class res2 extends proto2 {}
|
|
24
|
-
|
|
25
|
-
class res3 extends proto3 {}
|
|
26
|
-
|
|
27
|
-
console.log(res1.run("res 1 - "));
|
|
28
|
-
console.log(res1.faster("res 1 - "));
|
|
29
|
-
console.log(proto3.run("proto 3 - "));
|
|
30
|
-
console.log(res3.run("res 3 - "));
|
|
31
|
-
console.log(res2.faster("res 2 - "));
|
package/static2.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
class Parent {
|
|
2
|
-
static getOptions() {
|
|
3
|
-
return this.#options;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static setOptions(opts) {
|
|
7
|
-
this.#options = opts;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
class Child extends Parent {
|
|
12
|
-
static #options = {};
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
run() {
|
|
18
|
-
Child.getOptions();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Parent.setOptions({ 1: "1" });
|
|
23
|
-
|
|
24
|
-
console.log(new Child().run());
|