not-node 6.0.6 → 6.0.8
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/bin/not-builder.js +416 -289
- package/package.json +14 -14
- package/src/identity/identity.js +0 -1
- package/src/identity/providers/session.js +8 -3
package/bin/not-builder.js
CHANGED
|
@@ -9,59 +9,59 @@
|
|
|
9
9
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
var argv = require("yargs").argv,
|
|
13
|
+
fs = require("fs"),
|
|
14
|
+
path = require("path"),
|
|
15
|
+
child_process = require("child_process"),
|
|
16
|
+
deepMerge = require("deepmerge"),
|
|
17
|
+
lib = require("../src/lib.js");
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
const TEMPLATES_EXT = ".html";
|
|
20
|
+
const SCRIPTS_EXT = ".js";
|
|
21
|
+
const STYLES_EXT = ".scss";
|
|
22
|
+
const COMMON_TEMPLATES = "common";
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
path = require('path'),
|
|
18
|
-
child_process = require('child_process'),
|
|
19
|
-
deepMerge = require('deepmerge'),
|
|
20
|
-
|
|
21
|
-
lib = require('../src/lib.js');
|
|
22
|
-
|
|
23
|
-
const TEMPLATES_EXT = '.html';
|
|
24
|
-
const SCRIPTS_EXT = '.js';
|
|
25
|
-
const STYLES_EXT = '.scss';
|
|
26
|
-
const COMMON_TEMPLATES = 'common';
|
|
27
|
-
|
|
28
|
-
console.log('NODE VERSION',process.version);
|
|
24
|
+
console.log("NODE VERSION", process.version);
|
|
29
25
|
|
|
30
26
|
let opts = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
environment: argv.environment || "production",
|
|
28
|
+
to: argv.to || false,
|
|
29
|
+
config: argv.config || "./project.manifest.json",
|
|
30
|
+
rollup:
|
|
31
|
+
argv.rollup ||
|
|
32
|
+
path.join(process.cwd(), "./node_modules/.bin/rollup"),
|
|
33
|
+
role: argv.role || null,
|
|
34
|
+
verbose: argv.verbose || false,
|
|
37
35
|
},
|
|
38
36
|
configName = path.join(process.cwd(), opts.config),
|
|
39
37
|
config = {};
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
|
-
* Returns list of directories in directory
|
|
43
|
-
* @param {string} dir directory to search
|
|
44
|
-
* @return {Promise} of array of directories
|
|
45
|
-
*/
|
|
46
|
-
function listDir(dir){
|
|
47
|
-
return new Promise((resolve, reject)=>{
|
|
48
|
-
fs.stat(dir, (err_stat, info)=>{
|
|
49
|
-
if (err_stat){
|
|
40
|
+
* Returns list of directories in directory
|
|
41
|
+
* @param {string} dir directory to search
|
|
42
|
+
* @return {Promise} of array of directories
|
|
43
|
+
*/
|
|
44
|
+
function listDir(dir) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
fs.stat(dir, (err_stat, info) => {
|
|
47
|
+
if (err_stat) {
|
|
50
48
|
reject(err_stat);
|
|
51
|
-
}else{
|
|
52
|
-
if (info){
|
|
53
|
-
fs.readdir(dir, (err_readdir, files)=>{
|
|
54
|
-
if(err_readdir){
|
|
55
|
-
reject(
|
|
56
|
-
}else{
|
|
57
|
-
files = files.filter((item)=>{
|
|
58
|
-
return fs
|
|
49
|
+
} else {
|
|
50
|
+
if (info) {
|
|
51
|
+
fs.readdir(dir, (err_readdir, files) => {
|
|
52
|
+
if (err_readdir) {
|
|
53
|
+
reject("Error while reading directory file list.");
|
|
54
|
+
} else {
|
|
55
|
+
files = files.filter((item) => {
|
|
56
|
+
return fs
|
|
57
|
+
.lstatSync(path.join(dir, item))
|
|
58
|
+
.isDirectory();
|
|
59
59
|
});
|
|
60
60
|
resolve(files);
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
}else{
|
|
64
|
-
reject(
|
|
63
|
+
} else {
|
|
64
|
+
reject("Not exists!");
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
});
|
|
@@ -69,78 +69,77 @@ function listDir(dir){
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Returns list of files in directory
|
|
73
|
-
* @param {string} dir directory to search
|
|
74
|
-
* @return {Promise} of array of files
|
|
75
|
-
*/
|
|
76
|
-
function listFiles(dir, ext){
|
|
72
|
+
* Returns list of files in directory
|
|
73
|
+
* @param {string} dir directory to search
|
|
74
|
+
* @return {Promise} of array of files
|
|
75
|
+
*/
|
|
76
|
+
function listFiles(dir, ext) {
|
|
77
77
|
//console.info('list files in ',dir,' for ', ext);
|
|
78
|
-
return new Promise((resolve, reject)=>{
|
|
79
|
-
fs.stat(dir, (err_stat, info)=>{
|
|
80
|
-
if (err_stat){
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
fs.stat(dir, (err_stat, info) => {
|
|
80
|
+
if (err_stat) {
|
|
81
81
|
reject(err_stat);
|
|
82
|
-
}else{
|
|
83
|
-
if (info){
|
|
84
|
-
fs.readdir(dir, (err_readdir, files)=>{
|
|
85
|
-
if(err_readdir){
|
|
86
|
-
reject(
|
|
87
|
-
}else{
|
|
82
|
+
} else {
|
|
83
|
+
if (info) {
|
|
84
|
+
fs.readdir(dir, (err_readdir, files) => {
|
|
85
|
+
if (err_readdir) {
|
|
86
|
+
reject("Error while reading directory file list.");
|
|
87
|
+
} else {
|
|
88
88
|
//console.log(files);
|
|
89
|
-
files = files.filter((item)=>{
|
|
90
|
-
if
|
|
89
|
+
files = files.filter((item) => {
|
|
90
|
+
if (
|
|
91
|
+
!fs.lstatSync(path.join(dir, item)).isFile()
|
|
92
|
+
) {
|
|
91
93
|
//console.log(item, 'is not a file');
|
|
92
94
|
return false;
|
|
93
95
|
}
|
|
94
|
-
if(item.indexOf(ext)
|
|
96
|
+
if (item.indexOf(ext) === -1) {
|
|
95
97
|
//console.log(item, 'wrong ext 1');
|
|
96
98
|
return false;
|
|
97
99
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
100
|
+
let diff = item.length - ext.length;
|
|
101
|
+
return diff === item.indexOf(ext);
|
|
103
102
|
});
|
|
104
103
|
resolve(files);
|
|
105
104
|
}
|
|
106
105
|
});
|
|
107
|
-
}else{
|
|
108
|
-
reject(
|
|
106
|
+
} else {
|
|
107
|
+
reject("Not exists!");
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
async function fileExists(filename){
|
|
116
|
-
try{
|
|
114
|
+
async function fileExists(filename) {
|
|
115
|
+
try {
|
|
117
116
|
await fs.promises.access(filename, fs.constants.R_OK);
|
|
118
117
|
return true;
|
|
119
|
-
}catch(_){
|
|
118
|
+
} catch (_) {
|
|
120
119
|
//console.error('not exists', filename);
|
|
121
120
|
return false;
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
async function indexFilesExistsInDir(dir, exts = [
|
|
126
|
-
let filenamesList = exts.map(ext => path.join(dir, `index.${ext}`));
|
|
127
|
-
let checks = filenamesList.map(filename => fileExists(filename));
|
|
124
|
+
async function indexFilesExistsInDir(dir, exts = ["js"]) {
|
|
125
|
+
let filenamesList = exts.map((ext) => path.join(dir, `index.${ext}`));
|
|
126
|
+
let checks = filenamesList.map((filename) => fileExists(filename));
|
|
128
127
|
let results = await Promise.all(checks);
|
|
129
128
|
//console.log(results.some(res => res));
|
|
130
|
-
return results.some(res => res);
|
|
129
|
+
return results.some((res) => res);
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
/**
|
|
134
|
-
* Returns list of full path to files in directory
|
|
135
|
-
* @param {string} dir path to directory
|
|
136
|
-
* @return {array} list of full files paths
|
|
137
|
-
*/
|
|
138
|
-
async function listFilesPaths(dir, ext){
|
|
133
|
+
* Returns list of full path to files in directory
|
|
134
|
+
* @param {string} dir path to directory
|
|
135
|
+
* @return {array} list of full files paths
|
|
136
|
+
*/
|
|
137
|
+
async function listFilesPaths(dir, ext) {
|
|
139
138
|
let listOfFiles,
|
|
140
139
|
result = [];
|
|
141
|
-
try{
|
|
140
|
+
try {
|
|
142
141
|
listOfFiles = await listFiles(dir, ext);
|
|
143
|
-
}catch(e){
|
|
142
|
+
} catch (e) {
|
|
144
143
|
console.error(e);
|
|
145
144
|
}
|
|
146
145
|
listOfFiles.forEach((filename) => {
|
|
@@ -150,26 +149,30 @@ async function listFilesPaths(dir, ext){
|
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
/**
|
|
153
|
-
* Loads template files for specific role
|
|
154
|
-
* @param {string} dir path to templates directory
|
|
155
|
-
* @param {string} role user role
|
|
156
|
-
* @return {array} list of template files
|
|
157
|
-
*/
|
|
158
|
-
async function loadTemplates(
|
|
152
|
+
* Loads template files for specific role
|
|
153
|
+
* @param {string} dir path to templates directory
|
|
154
|
+
* @param {string} role user role
|
|
155
|
+
* @return {array} list of template files
|
|
156
|
+
*/
|
|
157
|
+
async function loadTemplates(
|
|
158
|
+
dir,
|
|
159
|
+
role = COMMON_TEMPLATES,
|
|
160
|
+
templatesExt = TEMPLATES_EXT
|
|
161
|
+
) {
|
|
159
162
|
let dirsList = await listDir(dir),
|
|
160
163
|
filesList = await listFiles(dir, templatesExt),
|
|
161
164
|
result = [];
|
|
162
|
-
if (dirsList && Array.isArray(dirsList) && dirsList.length > 0){
|
|
163
|
-
if (dirsList.indexOf(role) > -1){
|
|
165
|
+
if (dirsList && Array.isArray(dirsList) && dirsList.length > 0) {
|
|
166
|
+
if (dirsList.indexOf(role) > -1) {
|
|
164
167
|
let pathToModRole = path.join(dir, role),
|
|
165
168
|
files = await listFilesPaths(pathToModRole, templatesExt);
|
|
166
|
-
if(Array.isArray(files)){
|
|
169
|
+
if (Array.isArray(files)) {
|
|
167
170
|
result.push(...files);
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
|
-
if(filesList && Array.isArray(filesList) && filesList.length > 0){
|
|
172
|
-
if (filesList.indexOf(role + templatesExt) > -1){
|
|
174
|
+
if (filesList && Array.isArray(filesList) && filesList.length > 0) {
|
|
175
|
+
if (filesList.indexOf(role + templatesExt) > -1) {
|
|
173
176
|
result.push(path.join(dir, role + templatesExt));
|
|
174
177
|
}
|
|
175
178
|
}
|
|
@@ -178,409 +181,533 @@ async function loadTemplates(dir, role = COMMON_TEMPLATES, templatesExt = TEMPLA
|
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
/**
|
|
181
|
-
* Loads template files for specific role from front-end app
|
|
182
|
-
* @param {string} dir path to templates directory
|
|
183
|
-
* @param {string} role user role
|
|
184
|
-
* @return {array} list of template files
|
|
185
|
-
*/
|
|
186
|
-
async function loadTemplatesForFront(
|
|
184
|
+
* Loads template files for specific role from front-end app
|
|
185
|
+
* @param {string} dir path to templates directory
|
|
186
|
+
* @param {string} role user role
|
|
187
|
+
* @return {array} list of template files
|
|
188
|
+
*/
|
|
189
|
+
async function loadTemplatesForFront(
|
|
190
|
+
dir,
|
|
191
|
+
role,
|
|
192
|
+
commonDir = COMMON_TEMPLATES,
|
|
193
|
+
templatesExt = TEMPLATES_EXT
|
|
194
|
+
) {
|
|
187
195
|
let listDirs,
|
|
188
196
|
roleDir = path.join(dir, role),
|
|
189
197
|
result = [];
|
|
190
198
|
commonDir = path.join(dir, commonDir);
|
|
191
|
-
try{
|
|
199
|
+
try {
|
|
192
200
|
listDirs = await listDir(dir);
|
|
193
|
-
}catch(e){
|
|
201
|
+
} catch (e) {
|
|
194
202
|
console.error(e);
|
|
195
203
|
}
|
|
196
204
|
//console.log('listDirs:', listDirs);
|
|
197
|
-
try{
|
|
198
|
-
if(fs.lstatSync(commonDir).isDirectory()){
|
|
205
|
+
try {
|
|
206
|
+
if (fs.lstatSync(commonDir).isDirectory()) {
|
|
199
207
|
//console.log('Directory ', commonDir, ' exists!');
|
|
200
208
|
let files = await listFilesPaths(commonDir, templatesExt);
|
|
201
209
|
//console.log('common files:', files);
|
|
202
210
|
result.push(...files);
|
|
203
|
-
}else{
|
|
211
|
+
} else {
|
|
204
212
|
//console.log('no such directory', commonDir);
|
|
205
213
|
}
|
|
206
|
-
}catch(e){
|
|
214
|
+
} catch (e) {
|
|
207
215
|
console.error(e);
|
|
208
216
|
}
|
|
209
|
-
if(fs.lstatSync(roleDir).isDirectory()){
|
|
217
|
+
if (fs.lstatSync(roleDir).isDirectory()) {
|
|
210
218
|
let modsDir;
|
|
211
|
-
try{
|
|
219
|
+
try {
|
|
212
220
|
modsDir = await listDir(roleDir);
|
|
213
|
-
}catch(e){
|
|
221
|
+
} catch (e) {
|
|
214
222
|
console.error(e);
|
|
215
223
|
}
|
|
216
224
|
//console.log('!front ',role,roleDir,modsDir);
|
|
217
|
-
if(Array.isArray(modsDir)){
|
|
218
|
-
for(let t = 0; t < modsDir.length; t++){
|
|
225
|
+
if (Array.isArray(modsDir)) {
|
|
226
|
+
for (let t = 0; t < modsDir.length; t++) {
|
|
219
227
|
let modDir = modsDir[t];
|
|
220
|
-
let files = await listFilesPaths(
|
|
228
|
+
let files = await listFilesPaths(
|
|
229
|
+
path.join(roleDir, modDir),
|
|
230
|
+
templatesExt
|
|
231
|
+
);
|
|
221
232
|
//console.log('list of files', files);
|
|
222
233
|
result.push(...files);
|
|
223
234
|
}
|
|
224
235
|
}
|
|
225
|
-
}else{
|
|
226
|
-
console.error(
|
|
236
|
+
} else {
|
|
237
|
+
console.error("Directory is not exists: ", roleDir);
|
|
227
238
|
}
|
|
228
239
|
return result;
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
/**
|
|
232
|
-
* Loads information in not-* style module installed through NPM,
|
|
233
|
-
* that mentioned in [targetManifest].modules.npm
|
|
234
|
-
* @param {string} modName mondule name
|
|
235
|
-
* @param {object} modOptions module options from [targetManifest].modules.npm[moduleName]
|
|
236
|
-
* @param {array} roles used user roles
|
|
237
|
-
* @returns {object} result[role][controller]
|
|
238
|
-
*/
|
|
239
|
-
async function loadNPMModule(){
|
|
243
|
+
* Loads information in not-* style module installed through NPM,
|
|
244
|
+
* that mentioned in [targetManifest].modules.npm
|
|
245
|
+
* @param {string} modName mondule name
|
|
246
|
+
* @param {object} modOptions module options from [targetManifest].modules.npm[moduleName]
|
|
247
|
+
* @param {array} roles used user roles
|
|
248
|
+
* @returns {object} result[role][controller]
|
|
249
|
+
*/
|
|
250
|
+
async function loadNPMModule() {
|
|
240
251
|
let result = {};
|
|
241
|
-
try{
|
|
242
|
-
let {modName, modOptions, roles} = arguments[0];
|
|
252
|
+
try {
|
|
253
|
+
let { modName, modOptions, roles } = arguments[0];
|
|
243
254
|
let mod = require(modName);
|
|
244
|
-
for(let i = 0; i < roles.length; i++){
|
|
255
|
+
for (let i = 0; i < roles.length; i++) {
|
|
245
256
|
result[roles[i]] = {
|
|
246
|
-
controllers:[],
|
|
247
|
-
templates:
|
|
248
|
-
styles:
|
|
257
|
+
controllers: [],
|
|
258
|
+
templates: [],
|
|
259
|
+
styles: [],
|
|
249
260
|
};
|
|
250
261
|
}
|
|
251
262
|
|
|
252
|
-
if (mod.paths){
|
|
253
|
-
if(mod.paths.controllers){
|
|
263
|
+
if (mod.paths) {
|
|
264
|
+
if (mod.paths.controllers) {
|
|
254
265
|
let pathToControllers = mod.paths.controllers;
|
|
255
266
|
let dirList = await listDir(pathToControllers);
|
|
256
|
-
if (dirList && Array.isArray(dirList) && dirList.length > 0){
|
|
267
|
+
if (dirList && Array.isArray(dirList) && dirList.length > 0) {
|
|
257
268
|
let common = dirList.indexOf(COMMON_TEMPLATES) > -1;
|
|
258
|
-
roles.forEach((role)=>{
|
|
259
|
-
if (dirList.indexOf(role) > -1){
|
|
260
|
-
result[role].controllers.push(
|
|
269
|
+
roles.forEach((role) => {
|
|
270
|
+
if (dirList.indexOf(role) > -1) {
|
|
271
|
+
result[role].controllers.push(
|
|
272
|
+
path.join(pathToControllers, role)
|
|
273
|
+
);
|
|
261
274
|
}
|
|
262
|
-
if(common){
|
|
263
|
-
result[role].controllers.push(
|
|
275
|
+
if (common) {
|
|
276
|
+
result[role].controllers.push(
|
|
277
|
+
path.join(pathToControllers, "common")
|
|
278
|
+
);
|
|
264
279
|
}
|
|
265
280
|
});
|
|
266
281
|
}
|
|
267
282
|
}
|
|
268
|
-
if(mod.paths.templates){
|
|
283
|
+
if (mod.paths.templates) {
|
|
269
284
|
let commons;
|
|
270
|
-
try{
|
|
285
|
+
try {
|
|
271
286
|
commons = await loadTemplates(mod.paths.templates);
|
|
272
|
-
}catch(e){
|
|
287
|
+
} catch (e) {
|
|
273
288
|
console.error(e);
|
|
274
289
|
commons = [];
|
|
275
290
|
}
|
|
276
|
-
for(let role of roles){
|
|
291
|
+
for (let role of roles) {
|
|
277
292
|
let list = await loadTemplates(mod.paths.templates, role);
|
|
278
293
|
list.push(...commons);
|
|
279
294
|
result[role].templates.push(...list);
|
|
280
295
|
}
|
|
281
|
-
opts.verbose && console.log(
|
|
282
|
-
}else{
|
|
283
|
-
opts.verbose && console.info(
|
|
296
|
+
opts.verbose && console.log("result", result);
|
|
297
|
+
} else {
|
|
298
|
+
opts.verbose && console.info("...no templates");
|
|
284
299
|
}
|
|
285
|
-
if(mod.paths.styles){
|
|
300
|
+
if (mod.paths.styles) {
|
|
286
301
|
let commons;
|
|
287
|
-
try{
|
|
288
|
-
commons = await loadTemplates(
|
|
289
|
-
|
|
302
|
+
try {
|
|
303
|
+
commons = await loadTemplates(
|
|
304
|
+
mod.paths.styles,
|
|
305
|
+
COMMON_TEMPLATES,
|
|
306
|
+
STYLES_EXT
|
|
307
|
+
);
|
|
308
|
+
} catch (e) {
|
|
290
309
|
console.error(e);
|
|
291
310
|
commons = [];
|
|
292
311
|
}
|
|
293
|
-
for(let role of roles){
|
|
294
|
-
let list = await loadTemplates(
|
|
312
|
+
for (let role of roles) {
|
|
313
|
+
let list = await loadTemplates(
|
|
314
|
+
mod.paths.styles,
|
|
315
|
+
role,
|
|
316
|
+
STYLES_EXT
|
|
317
|
+
);
|
|
295
318
|
list.push(...commons);
|
|
296
319
|
result[role].styles.push(...list);
|
|
297
320
|
}
|
|
298
|
-
opts.verbose && console.log(
|
|
299
|
-
}else{
|
|
300
|
-
opts.verbose && console.info(
|
|
321
|
+
opts.verbose && console.log("result", result);
|
|
322
|
+
} else {
|
|
323
|
+
opts.verbose && console.info("...no styles");
|
|
301
324
|
}
|
|
302
325
|
}
|
|
303
|
-
}catch(e){
|
|
326
|
+
} catch (e) {
|
|
304
327
|
console.error(e);
|
|
305
328
|
}
|
|
306
|
-
opts.verbose && console.log(
|
|
329
|
+
opts.verbose && console.log("npm module content ", result);
|
|
307
330
|
return result;
|
|
308
331
|
}
|
|
309
332
|
|
|
310
|
-
async function loadServerModule(){
|
|
333
|
+
async function loadServerModule() {
|
|
311
334
|
let result = {};
|
|
312
|
-
try{
|
|
313
|
-
let {modName, modOptions, roles, pathToModule} = arguments[0];
|
|
335
|
+
try {
|
|
336
|
+
let { modName, modOptions, roles, pathToModule } = arguments[0];
|
|
314
337
|
let mod = require(pathToModule);
|
|
315
|
-
for(let i = 0; i < roles.length; i++){
|
|
338
|
+
for (let i = 0; i < roles.length; i++) {
|
|
316
339
|
result[roles[i]] = {
|
|
317
|
-
controllers:[],
|
|
318
|
-
templates:
|
|
319
|
-
styles:
|
|
340
|
+
controllers: [],
|
|
341
|
+
templates: [],
|
|
342
|
+
styles: [],
|
|
320
343
|
};
|
|
321
344
|
}
|
|
322
|
-
if (mod.paths){
|
|
323
|
-
if(
|
|
345
|
+
if (mod.paths) {
|
|
346
|
+
if (mod.paths.controllers) {
|
|
324
347
|
let pathToControllers = mod.paths.controllers;
|
|
325
348
|
//console.log(pathToControllers);
|
|
326
349
|
let dirList = await listDir(pathToControllers);
|
|
327
350
|
//console.log(dirList);
|
|
328
|
-
if (dirList && Array.isArray(dirList) && dirList.length > 0){
|
|
329
|
-
for(let i = 0; i < roles.length; i++){
|
|
351
|
+
if (dirList && Array.isArray(dirList) && dirList.length > 0) {
|
|
352
|
+
for (let i = 0; i < roles.length; i++) {
|
|
330
353
|
let role = roles[i];
|
|
331
|
-
if(dirList.indexOf("common") > -1){
|
|
332
|
-
let pathToModRole = path.join(
|
|
333
|
-
|
|
354
|
+
if (dirList.indexOf("common") > -1) {
|
|
355
|
+
let pathToModRole = path.join(
|
|
356
|
+
pathToControllers,
|
|
357
|
+
"common"
|
|
358
|
+
);
|
|
359
|
+
if (await indexFilesExistsInDir(pathToModRole)) {
|
|
334
360
|
result[role].controllers.push(pathToModRole);
|
|
335
361
|
}
|
|
336
362
|
}
|
|
337
|
-
if (dirList.indexOf(role)
|
|
338
|
-
let pathToModRole = path.join(
|
|
363
|
+
if (dirList.indexOf(role) > -1) {
|
|
364
|
+
let pathToModRole = path.join(
|
|
365
|
+
pathToControllers,
|
|
366
|
+
role
|
|
367
|
+
);
|
|
339
368
|
result[role].controllers.push(pathToModRole);
|
|
340
|
-
|
|
341
369
|
}
|
|
342
370
|
}
|
|
343
371
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
opts.verbose && console.info('...no controllers');
|
|
372
|
+
} else {
|
|
373
|
+
opts.verbose && console.info("...no controllers");
|
|
347
374
|
}
|
|
348
|
-
if(mod.paths.templates){
|
|
375
|
+
if (mod.paths.templates) {
|
|
349
376
|
let commons;
|
|
350
|
-
try{
|
|
377
|
+
try {
|
|
351
378
|
commons = await loadTemplates(mod.paths.templates);
|
|
352
|
-
}catch(e){
|
|
379
|
+
} catch (e) {
|
|
353
380
|
console.error(e);
|
|
354
381
|
commons = [];
|
|
355
382
|
}
|
|
356
383
|
//console.log('commons', commons);
|
|
357
|
-
for(let i = 0; i < roles.length; i++){
|
|
358
|
-
try{
|
|
384
|
+
for (let i = 0; i < roles.length; i++) {
|
|
385
|
+
try {
|
|
359
386
|
//console.log('loadTemplates', typeof loadTemplates);
|
|
360
387
|
let role = roles[i],
|
|
361
|
-
list = await loadTemplates(
|
|
388
|
+
list = await loadTemplates(
|
|
389
|
+
mod.paths.templates,
|
|
390
|
+
role
|
|
391
|
+
);
|
|
362
392
|
//console.log('list', typeof list, typeof result[role]);
|
|
363
|
-
list.push(...
|
|
393
|
+
list.push(...commons.slice());
|
|
364
394
|
result[role].templates.push(...list);
|
|
365
|
-
}catch(e){
|
|
395
|
+
} catch (e) {
|
|
366
396
|
console.error(e);
|
|
367
397
|
}
|
|
368
|
-
|
|
369
398
|
}
|
|
370
|
-
}else{
|
|
371
|
-
opts.verbose && console.info(
|
|
399
|
+
} else {
|
|
400
|
+
opts.verbose && console.info("...no templates");
|
|
372
401
|
}
|
|
373
|
-
if(mod.paths.styles){
|
|
402
|
+
if (mod.paths.styles) {
|
|
374
403
|
let commons;
|
|
375
|
-
try{
|
|
376
|
-
commons = await loadTemplates(
|
|
377
|
-
|
|
404
|
+
try {
|
|
405
|
+
commons = await loadTemplates(
|
|
406
|
+
mod.paths.styles,
|
|
407
|
+
COMMON_TEMPLATES,
|
|
408
|
+
STYLES_EXT
|
|
409
|
+
);
|
|
410
|
+
} catch (e) {
|
|
378
411
|
console.error(e);
|
|
379
412
|
commons = [];
|
|
380
413
|
}
|
|
381
414
|
//console.log('commons', commons);
|
|
382
|
-
for(let i = 0; i < roles.length; i++){
|
|
383
|
-
try{
|
|
415
|
+
for (let i = 0; i < roles.length; i++) {
|
|
416
|
+
try {
|
|
384
417
|
//console.log('loadTemplates', typeof loadTemplates);
|
|
385
418
|
let role = roles[i],
|
|
386
|
-
list = await loadTemplates(
|
|
419
|
+
list = await loadTemplates(
|
|
420
|
+
mod.paths.styles,
|
|
421
|
+
role,
|
|
422
|
+
STYLES_EXT
|
|
423
|
+
);
|
|
387
424
|
//console.log('list', typeof list, typeof result[role]);
|
|
388
|
-
list.push(...
|
|
425
|
+
list.push(...commons.slice());
|
|
389
426
|
result[role].styles.push(...list);
|
|
390
|
-
}catch(e){
|
|
427
|
+
} catch (e) {
|
|
391
428
|
console.error(e);
|
|
392
429
|
}
|
|
393
|
-
|
|
394
430
|
}
|
|
395
|
-
}else{
|
|
396
|
-
opts.verbose && console.info(
|
|
431
|
+
} else {
|
|
432
|
+
opts.verbose && console.info("...no styles");
|
|
397
433
|
}
|
|
398
434
|
}
|
|
399
|
-
}catch(e){
|
|
435
|
+
} catch (e) {
|
|
400
436
|
console.error(e);
|
|
401
437
|
}
|
|
402
438
|
return result;
|
|
403
439
|
}
|
|
404
440
|
|
|
405
|
-
function initList(roles, pathTo){
|
|
441
|
+
function initList(roles, pathTo) {
|
|
406
442
|
let list = {};
|
|
407
|
-
for(let i = 0; i < roles.length; i++){
|
|
443
|
+
for (let i = 0; i < roles.length; i++) {
|
|
408
444
|
list[roles[i]] = {
|
|
409
|
-
templates:
|
|
410
|
-
controllers:
|
|
411
|
-
styles:
|
|
445
|
+
templates: [],
|
|
446
|
+
controllers: [],
|
|
447
|
+
styles: [],
|
|
412
448
|
};
|
|
413
|
-
if (pathTo){
|
|
449
|
+
if (pathTo) {
|
|
414
450
|
list[roles[i]].controllers.push(pathTo);
|
|
415
451
|
}
|
|
416
452
|
}
|
|
417
453
|
return list;
|
|
418
454
|
}
|
|
419
455
|
|
|
420
|
-
async function loadFrontModules(){
|
|
456
|
+
async function loadFrontModules() {
|
|
421
457
|
let result = {};
|
|
422
|
-
try{
|
|
423
|
-
let {modsOptions, roles, pathToModules} = arguments[0];
|
|
424
|
-
for(let i = 0; i < roles.length; i++){
|
|
458
|
+
try {
|
|
459
|
+
let { modsOptions, roles, pathToModules } = arguments[0];
|
|
460
|
+
for (let i = 0; i < roles.length; i++) {
|
|
425
461
|
result[roles[i]] = {
|
|
426
|
-
templates:
|
|
427
|
-
controllers:
|
|
428
|
-
styles:
|
|
462
|
+
templates: [],
|
|
463
|
+
controllers: [],
|
|
464
|
+
styles: [],
|
|
429
465
|
};
|
|
430
466
|
}
|
|
431
467
|
let modulesDirList = await listDir(pathToModules);
|
|
432
|
-
if (modulesDirList.indexOf(
|
|
433
|
-
result = initList(roles, path.join(pathToModules,
|
|
468
|
+
if (modulesDirList.indexOf("common") > -1) {
|
|
469
|
+
result = initList(roles, path.join(pathToModules, "common"));
|
|
434
470
|
}
|
|
435
471
|
//console.log(modulesDirList);
|
|
436
|
-
for(let i = 0; i < roles.length; i++){
|
|
472
|
+
for (let i = 0; i < roles.length; i++) {
|
|
437
473
|
modulesDirList = await listDir(path.join(pathToModules, roles[i]));
|
|
438
474
|
//console.log(path.join(pathToModules, roles[i]), modulesDirList);
|
|
439
|
-
for(let t = 0; t < modulesDirList.length; t++){
|
|
440
|
-
result[roles[i]].controllers.push(
|
|
475
|
+
for (let t = 0; t < modulesDirList.length; t++) {
|
|
476
|
+
result[roles[i]].controllers.push(
|
|
477
|
+
path.join(pathToModules, roles[i], modulesDirList[t])
|
|
478
|
+
);
|
|
441
479
|
}
|
|
442
480
|
//console.log(result[roles[i]].controllers);
|
|
443
481
|
//console.log('role:', roles[i]);
|
|
444
|
-
result[roles[i]].templates = await loadTemplatesForFront(
|
|
445
|
-
|
|
482
|
+
result[roles[i]].templates = await loadTemplatesForFront(
|
|
483
|
+
pathToModules,
|
|
484
|
+
roles[i]
|
|
485
|
+
);
|
|
486
|
+
result[roles[i]].styles = await loadTemplatesForFront(
|
|
487
|
+
pathToModules,
|
|
488
|
+
roles[i],
|
|
489
|
+
COMMON_TEMPLATES,
|
|
490
|
+
STYLES_EXT
|
|
491
|
+
);
|
|
446
492
|
//console.log('templates in there', result[roles[i]].templates);
|
|
447
493
|
}
|
|
448
|
-
}catch(e){
|
|
449
|
-
console.error(
|
|
494
|
+
} catch (e) {
|
|
495
|
+
console.error("loadFrontModules error", e);
|
|
450
496
|
}
|
|
451
497
|
return result;
|
|
452
498
|
}
|
|
453
499
|
|
|
454
|
-
async function loadServerModulesFromDir(){
|
|
500
|
+
async function loadServerModulesFromDir() {
|
|
455
501
|
let list = {};
|
|
456
|
-
try{
|
|
457
|
-
let {modsOptions, roles, pathToModules} = arguments[0];
|
|
502
|
+
try {
|
|
503
|
+
let { modsOptions, roles, pathToModules } = arguments[0];
|
|
458
504
|
let modulesDirList = await listDir(pathToModules);
|
|
459
|
-
for(let i = 0; i < modulesDirList.length; i++){
|
|
505
|
+
for (let i = 0; i < modulesDirList.length; i++) {
|
|
460
506
|
let moduleName = modulesDirList[i];
|
|
461
|
-
console.info(
|
|
462
|
-
let modOptions =
|
|
507
|
+
console.info("Import from", moduleName);
|
|
508
|
+
let modOptions =
|
|
509
|
+
modsOptions && modsOptions.hasOwnProperty[moduleName]
|
|
510
|
+
? modsOptions[moduleName]
|
|
511
|
+
: {};
|
|
463
512
|
let pathToModule = path.join(pathToModules, moduleName);
|
|
464
|
-
let partList = await loadServerModule({
|
|
513
|
+
let partList = await loadServerModule({
|
|
514
|
+
pathToModule,
|
|
515
|
+
roles,
|
|
516
|
+
modName: moduleName,
|
|
517
|
+
modOptions,
|
|
518
|
+
});
|
|
465
519
|
list = deepMerge(list, partList);
|
|
466
520
|
}
|
|
467
|
-
}catch(e){
|
|
521
|
+
} catch (e) {
|
|
468
522
|
console.error(e);
|
|
469
523
|
}
|
|
470
524
|
return list;
|
|
471
525
|
}
|
|
472
526
|
|
|
527
|
+
function getFileNameByTemplateAndRole(template, role) {
|
|
528
|
+
let parts = path.parse(template);
|
|
529
|
+
return parts.base.replace("!", role);
|
|
530
|
+
}
|
|
473
531
|
|
|
474
|
-
|
|
475
|
-
let
|
|
476
|
-
for(let i = 0; i < roles.length; i++){
|
|
532
|
+
function initListByRoles(list, roles) {
|
|
533
|
+
for (let i = 0; i < roles.length; i++) {
|
|
477
534
|
list[roles[i]] = {
|
|
478
|
-
controllers:[],
|
|
479
|
-
templates:
|
|
480
|
-
styles:
|
|
535
|
+
controllers: [],
|
|
536
|
+
templates: [],
|
|
537
|
+
styles: [],
|
|
481
538
|
};
|
|
482
539
|
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
async function build_Server(pathToRoot, roles, targetName, targetManifest) {
|
|
543
|
+
let list = {};
|
|
544
|
+
initListByRoles(list, roles);
|
|
483
545
|
////searching for app.js template
|
|
484
546
|
////searching modules
|
|
485
547
|
let pathTo = {
|
|
486
|
-
|
|
487
|
-
|
|
548
|
+
nodeModules:
|
|
549
|
+
targetManifest.modules && targetManifest.modules.serverModulesDir
|
|
550
|
+
? path.join(pathToRoot, targetManifest.modules.serverModulesDir)
|
|
551
|
+
: undefined,
|
|
552
|
+
frontModules:
|
|
553
|
+
targetManifest.modules && targetManifest.modules.frontModulesDir
|
|
554
|
+
? path.join(pathToRoot, targetManifest.modules.frontModulesDir)
|
|
555
|
+
: undefined,
|
|
488
556
|
};
|
|
489
|
-
if (targetManifest.modules){
|
|
557
|
+
if (targetManifest.modules) {
|
|
490
558
|
/////searching for npm modules
|
|
491
|
-
if (targetManifest.modules.npm){
|
|
559
|
+
if (targetManifest.modules.npm) {
|
|
492
560
|
let mass = targetManifest.modules.npm;
|
|
493
|
-
console.info(
|
|
494
|
-
for(let t in mass){
|
|
495
|
-
console.info(t,
|
|
496
|
-
let partList = await loadNPMModule({
|
|
561
|
+
console.info("Import from npm modules:");
|
|
562
|
+
for (let t in mass) {
|
|
563
|
+
console.info(t, "...");
|
|
564
|
+
let partList = await loadNPMModule({
|
|
565
|
+
roles,
|
|
566
|
+
modName: t,
|
|
567
|
+
modOptions: mass[t],
|
|
568
|
+
});
|
|
497
569
|
list = deepMerge(list, partList);
|
|
498
570
|
}
|
|
499
|
-
}else{
|
|
500
|
-
console.info(
|
|
571
|
+
} else {
|
|
572
|
+
console.info("no npm modules in manifest");
|
|
501
573
|
}
|
|
502
574
|
/////searching for server modules
|
|
503
|
-
if (targetManifest.modules.serverModulesDir){
|
|
504
|
-
console.info(
|
|
505
|
-
|
|
575
|
+
if (targetManifest.modules.serverModulesDir) {
|
|
576
|
+
console.info(
|
|
577
|
+
"Import custom server modules from",
|
|
578
|
+
targetManifest.modules.serverModulesDir,
|
|
579
|
+
":"
|
|
580
|
+
);
|
|
581
|
+
let partList = await loadServerModulesFromDir({
|
|
582
|
+
pathToModules: path.join(
|
|
583
|
+
pathToRoot,
|
|
584
|
+
targetManifest.modules.serverModulesDir
|
|
585
|
+
),
|
|
586
|
+
roles,
|
|
587
|
+
modsOptions: targetManifest.modules.server,
|
|
588
|
+
});
|
|
506
589
|
list = deepMerge(list, partList);
|
|
507
|
-
}else{
|
|
508
|
-
console.info(
|
|
590
|
+
} else {
|
|
591
|
+
console.info("no custom server modules in manifest");
|
|
509
592
|
}
|
|
510
593
|
/////searching for front modules
|
|
511
|
-
if (targetManifest.modules.frontModulesDir){
|
|
512
|
-
console.info(
|
|
513
|
-
|
|
594
|
+
if (targetManifest.modules.frontModulesDir) {
|
|
595
|
+
console.info(
|
|
596
|
+
"Import custom front modules from",
|
|
597
|
+
targetManifest.modules.frontModulesDir,
|
|
598
|
+
":"
|
|
599
|
+
);
|
|
600
|
+
try {
|
|
514
601
|
let mass = targetManifest.modules.front;
|
|
515
|
-
let pathToModules = path.join(
|
|
516
|
-
|
|
602
|
+
let pathToModules = path.join(
|
|
603
|
+
pathToRoot,
|
|
604
|
+
targetManifest.modules.frontModulesDir
|
|
605
|
+
);
|
|
606
|
+
let partList = await loadFrontModules({
|
|
607
|
+
pathToModules,
|
|
608
|
+
roles,
|
|
609
|
+
modsOptions: mass,
|
|
610
|
+
});
|
|
517
611
|
list = deepMerge(list, partList);
|
|
518
|
-
}catch(e){
|
|
612
|
+
} catch (e) {
|
|
519
613
|
console.error(e);
|
|
520
614
|
}
|
|
521
|
-
}else{
|
|
522
|
-
console.info(
|
|
615
|
+
} else {
|
|
616
|
+
console.info("no front modules in manifest");
|
|
523
617
|
}
|
|
524
|
-
}else{
|
|
525
|
-
console.info(
|
|
618
|
+
} else {
|
|
619
|
+
console.info("no modules in manifest");
|
|
526
620
|
}
|
|
527
|
-
opts.verbose && console.log(
|
|
621
|
+
opts.verbose && console.log("List:", list);
|
|
528
622
|
////forming index.js and rollup.js
|
|
529
|
-
for(let i = 0; i < roles.length; i++){
|
|
623
|
+
for (let i = 0; i < roles.length; i++) {
|
|
530
624
|
const role = roles[i];
|
|
531
|
-
if(
|
|
625
|
+
if (opts.role !== null && opts.role !== role) {
|
|
532
626
|
continue;
|
|
533
627
|
}
|
|
534
|
-
try{
|
|
535
|
-
let indexFile = path.join(
|
|
536
|
-
|
|
537
|
-
|
|
628
|
+
try {
|
|
629
|
+
let indexFile = path.join(
|
|
630
|
+
pathToRoot,
|
|
631
|
+
targetManifest.src,
|
|
632
|
+
getFileNameByTemplateAndRole(targetManifest.index, role)
|
|
633
|
+
);
|
|
634
|
+
let rollupFile = path.join(
|
|
635
|
+
pathToRoot,
|
|
636
|
+
targetManifest.root,
|
|
637
|
+
getFileNameByTemplateAndRole(targetManifest.rollup, role)
|
|
638
|
+
);
|
|
639
|
+
let bundleFile = path.join(
|
|
640
|
+
pathToRoot,
|
|
641
|
+
targetManifest.build,
|
|
642
|
+
getFileNameByTemplateAndRole(
|
|
643
|
+
targetManifest.output || "!.js",
|
|
644
|
+
role
|
|
645
|
+
)
|
|
646
|
+
);
|
|
538
647
|
//let templateFile = path.join(pathToRoot, targetManifest.build, role + '.html');
|
|
539
|
-
await lib.renderScript(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
648
|
+
await lib.renderScript(
|
|
649
|
+
path.join(pathToRoot, targetManifest.index),
|
|
650
|
+
{
|
|
651
|
+
mods: list[role].controllers,
|
|
652
|
+
scss: list[role].styles,
|
|
653
|
+
env: opts.environment,
|
|
654
|
+
role,
|
|
655
|
+
},
|
|
656
|
+
indexFile
|
|
657
|
+
);
|
|
658
|
+
await lib.renderScript(
|
|
659
|
+
path.join(pathToRoot, targetManifest.rollup),
|
|
660
|
+
{
|
|
661
|
+
appName: targetManifest.name,
|
|
662
|
+
inputPath: indexFile,
|
|
663
|
+
outputPath: bundleFile,
|
|
664
|
+
env: opts.environment,
|
|
665
|
+
role,
|
|
666
|
+
},
|
|
667
|
+
rollupFile
|
|
668
|
+
);
|
|
669
|
+
let result = child_process.execFileSync(
|
|
670
|
+
"node",
|
|
671
|
+
[opts.rollup, "-c", rollupFile],
|
|
672
|
+
{
|
|
673
|
+
env: {
|
|
674
|
+
NODE_ENV: opts.environment,
|
|
675
|
+
},
|
|
555
676
|
}
|
|
556
|
-
|
|
677
|
+
);
|
|
678
|
+
//console.log(result.toString());
|
|
557
679
|
//await lib.joinToFile(templateFile, list[role].templates);
|
|
558
|
-
}catch(e){
|
|
680
|
+
} catch (e) {
|
|
559
681
|
console.error(e);
|
|
560
682
|
}
|
|
561
683
|
}
|
|
562
684
|
////executing rollup
|
|
563
|
-
|
|
564
685
|
}
|
|
565
686
|
|
|
566
687
|
//loading manifest file
|
|
567
|
-
try{
|
|
568
|
-
console.log(
|
|
688
|
+
try {
|
|
689
|
+
console.log("config path", configName);
|
|
569
690
|
config = lib.getConfReader(configName);
|
|
570
|
-
}catch(e){
|
|
691
|
+
} catch (e) {
|
|
571
692
|
console.error(e);
|
|
572
693
|
process.exit(1);
|
|
573
694
|
}
|
|
574
695
|
//searchig for targets
|
|
575
|
-
if (config.get(
|
|
696
|
+
if (config.get("targets") && Object.keys(config.get("targets")).length > 0) {
|
|
576
697
|
//cycling through targets
|
|
577
|
-
for(let target in config.get(
|
|
578
|
-
let targetConfig = config.get(
|
|
579
|
-
if (targetConfig && targetConfig.builder){
|
|
698
|
+
for (let target in config.get("targets")) {
|
|
699
|
+
let targetConfig = config.get("targets")[target];
|
|
700
|
+
if (targetConfig && targetConfig.builder) {
|
|
580
701
|
//if target type is server
|
|
581
|
-
switch (targetConfig.builder){
|
|
582
|
-
|
|
583
|
-
|
|
702
|
+
switch (targetConfig.builder) {
|
|
703
|
+
case "server":
|
|
704
|
+
build_Server(
|
|
705
|
+
path.dirname(configName),
|
|
706
|
+
targetConfig.roles,
|
|
707
|
+
target,
|
|
708
|
+
targetConfig
|
|
709
|
+
);
|
|
710
|
+
break;
|
|
584
711
|
}
|
|
585
712
|
}
|
|
586
713
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "not-node",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.8",
|
|
4
4
|
"description": "node complimentary part for client side notFramework.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"not-builder": "./bin/not-builder.js"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">
|
|
20
|
+
"node": ">14.9"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"url": "https://github.com/interrupter/not-node/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"body-parser": "^1.20.
|
|
36
|
+
"body-parser": "^1.20.1",
|
|
37
37
|
"compression": "^1.7.4",
|
|
38
38
|
"connect-mongodb-session": "^3.1.1",
|
|
39
39
|
"connect-redis": "^6.1.3",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"deepmerge": "^4.2.2",
|
|
43
43
|
"ejs": "^3.1.8",
|
|
44
44
|
"escape-string-regexp": "*",
|
|
45
|
-
"express": "^4.18.
|
|
45
|
+
"express": "^4.18.2",
|
|
46
46
|
"express-fileupload": "^1.4.0",
|
|
47
47
|
"express-session": "^1.17.3",
|
|
48
48
|
"fs-extra": "*",
|
|
49
|
-
"helmet": "^6.0.
|
|
50
|
-
"jsonwebtoken": "^
|
|
49
|
+
"helmet": "^6.0.1",
|
|
50
|
+
"jsonwebtoken": "^9.0.0",
|
|
51
51
|
"lower-case": "*",
|
|
52
52
|
"method-override": "^3.0.0",
|
|
53
53
|
"mock-require": "^3.0.3",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"not-monitor": "^0.0.13",
|
|
64
64
|
"not-path": "^1.0.4",
|
|
65
65
|
"not-validation": "^0.0.8",
|
|
66
|
-
"rate-limiter-flexible": "^2.
|
|
67
|
-
"redis": "^4.
|
|
66
|
+
"rate-limiter-flexible": "^2.4.1",
|
|
67
|
+
"redis": "^4.5.1",
|
|
68
68
|
"redlock": "^5.0.0-beta.2",
|
|
69
69
|
"rfdc": "^1.3.0",
|
|
70
70
|
"rmdir": "^1.2.0",
|
|
@@ -77,18 +77,18 @@
|
|
|
77
77
|
"babel-eslint": "^10.1.0",
|
|
78
78
|
"chai": "*",
|
|
79
79
|
"chai-as-promised": "*",
|
|
80
|
-
"eslint": "^8.
|
|
80
|
+
"eslint": "^8.30.0",
|
|
81
81
|
"eslint-plugin-node": "^11.1.0",
|
|
82
|
-
"eslint-plugin-sonarjs": "^0.
|
|
82
|
+
"eslint-plugin-sonarjs": "^0.17.0",
|
|
83
83
|
"ink-docstrap": "^1.3.2",
|
|
84
|
-
"ioredis": "^5.2.
|
|
85
|
-
"jsdoc": "^
|
|
84
|
+
"ioredis": "^5.2.4",
|
|
85
|
+
"jsdoc": "^4.0.0",
|
|
86
86
|
"mocha": "*",
|
|
87
87
|
"mocha-suppress-logs": "^0.3.1",
|
|
88
|
-
"mongodb-memory-server": "^8.
|
|
88
|
+
"mongodb-memory-server": "^8.10.2",
|
|
89
89
|
"npm-run-all": "^4.1.5",
|
|
90
90
|
"nyc": "^15.1.0",
|
|
91
|
-
"retire": "^3.
|
|
91
|
+
"retire": "^3.2.1"
|
|
92
92
|
},
|
|
93
93
|
"homepage": "https://github.com/interrupter/not-node#readme",
|
|
94
94
|
"nyc": {
|
package/src/identity/identity.js
CHANGED
|
@@ -33,9 +33,14 @@ module.exports = class IdentityProviderSession {
|
|
|
33
33
|
**/
|
|
34
34
|
getRole() {
|
|
35
35
|
const req = this.req;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (req && req.session) {
|
|
37
|
+
if (!req.session.role) {
|
|
38
|
+
this.setGuest();
|
|
39
|
+
}
|
|
40
|
+
return req.session.role;
|
|
41
|
+
} else {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
/**
|