not-node 6.5.40 → 6.5.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.5.40",
3
+ "version": "6.5.41",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,19 +28,19 @@ import Options from "./opts.mjs";
28
28
  const PATH_TMPL = Options.PATH_TMPL;
29
29
 
30
30
  async function renderFile(input, dest, data) {
31
- try{
31
+ try {
32
32
  Logger.log("render", dest);
33
33
  const renderedFileContent = await ejs.renderFile(input, data, {
34
34
  async: true,
35
35
  });
36
36
  await writeFile(dest, renderedFileContent);
37
- }catch(e){
37
+ } catch (e) {
38
38
  console.error(e);
39
39
  }
40
40
  }
41
41
 
42
42
  async function createFileContent(filePath, structure, config) {
43
- try{
43
+ try {
44
44
  if (typeof structure == "string") {
45
45
  await copyTmplFile(resolve(PATH_TMPL, structure), filePath);
46
46
  return;
@@ -50,7 +50,7 @@ async function createFileContent(filePath, structure, config) {
50
50
  const data = await readArgs(structure, config);
51
51
  await renderFile(tmplFilePath, filePath, data);
52
52
  }
53
- }catch(e){
53
+ } catch (e) {
54
54
  console.error(e);
55
55
  }
56
56
  }
@@ -240,7 +240,7 @@ async function findAllFieldsInModules(modulesDirPath) {
240
240
  const modulesNames = await readdir(modulesDirPath);
241
241
  const result = [];
242
242
  for (const moduleName of modulesNames) {
243
- if (moduleName && moduleName.indexOf("not-") === 0) {
243
+ if (moduleName && moduleName.indexOf("not-") === 0) {
244
244
  const listOfFieldsInModule = await findFieldsInModule(
245
245
  join(modulesDirPath, moduleName)
246
246
  );
@@ -253,7 +253,7 @@ async function findAllFieldsInModules(modulesDirPath) {
253
253
  fullName: `${moduleName}//${fieldName}`,
254
254
  };
255
255
  }
256
- );
256
+ );
257
257
  result.push(...listOfFieldsDescriptions);
258
258
  }
259
259
  }
@@ -265,18 +265,32 @@ async function findAllFieldsInModules(modulesDirPath) {
265
265
  }
266
266
  }
267
267
 
268
- async function findAllFieldsInNodeModules(siteDirPath) {
268
+ async function findAllFieldsInGlobalNodeModules() {
269
+ const result = [];
270
+ for (let globalLib of Options.DEFAULT_GLOBAL_NPM_LIB) {
271
+ const dirname = join(globalLib, "node_modules");
272
+ result.push(...(await findAllFieldsInModules(dirname)));
273
+ }
274
+ return result;
275
+ }
276
+
277
+ async function findAllFieldsInLocalNodeModules(siteDirPath) {
269
278
  const dirname = join(siteDirPath, "node_modules");
270
279
  return await findAllFieldsInModules(dirname);
271
280
  }
272
281
 
273
282
  async function findAllFields(siteDirPath, modulesDir) {
274
283
  try {
275
- const fieldsInNodeModules = await findAllFieldsInNodeModules(
284
+ const fieldsInGlobalNodeModules =
285
+ await findAllFieldsInGlobalNodeModules();
286
+ const fieldsInLocalNodeModules = await findAllFieldsInLocalNodeModules(
276
287
  siteDirPath
277
288
  );
278
289
  const fieldsInProjectModules = await findAllFieldsInModules(modulesDir);
279
- return [...fieldsInNodeModules, ...fieldsInProjectModules];
290
+ const fromNPM = fieldsInLocalNodeModules.length
291
+ ? fieldsInLocalNodeModules
292
+ : fieldsInGlobalNodeModules;
293
+ return [...fromNPM, ...fieldsInProjectModules];
280
294
  } catch (err) {
281
295
  console.error(err);
282
296
  return [];
@@ -75,7 +75,7 @@ async function renderServerContollersIndexes(
75
75
  }
76
76
  }
77
77
 
78
- async function createServerModule(modules_dir, config, availableFields) {
78
+ async function createServerModule(modules_dir, config, availableFields = []) {
79
79
  //read module name
80
80
  const ModuleName = await Readers.ModuleName(inquirer);
81
81
  const ModuleNameHumanReadable = moduleNameTransformer(ModuleName);
@@ -4,6 +4,11 @@ import * as url from "url";
4
4
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
5
5
 
6
6
  class Options {
7
+ #DEFAULT_GLOBAL_NPM_LIB = ["/usr/local/lib", "/usr/lib"];
8
+ get DEFAULT_GLOBAL_NPM_LIB() {
9
+ return this.#DEFAULT_GLOBAL_NPM_LIB;
10
+ }
11
+
7
12
  #DEFAULT_SITE_PATH = "./site";
8
13
  get DEFAULT_SITE_PATH() {
9
14
  return this.#DEFAULT_SITE_PATH;
@@ -4,7 +4,7 @@ const DEFAULT_CLIENT = "ioredis";
4
4
 
5
5
  module.exports = class InitSessionsRedis {
6
6
  async run({ config, options, master, emit }) {
7
- log.info("Setting up user sessions handler(redis)...");
7
+ log?.info("Setting up user sessions handler(redis)...");
8
8
  await emit("sessions.pre", { config, options, master });
9
9
  const expressSession = require("express-session");
10
10
  const storeClient = config.get("session.client", DEFAULT_CLIENT);