not-node 6.3.74 → 6.3.76

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.3.74",
3
+ "version": "6.3.76",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/env.js CHANGED
@@ -5,6 +5,7 @@ const ENVS = {
5
5
  };
6
6
 
7
7
  module.exports = class notEnv {
8
+ static LOG_STRING_ASSIGNMENTS = true;
8
9
  /**
9
10
  * Obsolete!
10
11
  * Wrapper for 'get'
@@ -52,6 +53,9 @@ module.exports = class notEnv {
52
53
  * @return {notEnv} chainable
53
54
  */
54
55
  static set(key, val) {
56
+ if (notEnv.LOG_STRING_ASSIGNMENTS && typeof val === "string") {
57
+ console.log("ENV SET ", key, " = ", val);
58
+ }
55
59
  ENVS[key] = val;
56
60
  return notEnv;
57
61
  }
package/src/init/index.js CHANGED
@@ -106,8 +106,8 @@ class Init {
106
106
  }
107
107
 
108
108
  static printOutManifest = () => {
109
- log.debug("Manifest:");
110
- log.debug(JSON.stringify(Init.notApp.getManifest(), null, 4));
109
+ log?.debug("Manifest:");
110
+ log?.debug(JSON.stringify(Init.notApp.getManifest(), null, 4));
111
111
  };
112
112
 
113
113
  /**
@@ -122,7 +122,7 @@ class Init {
122
122
 
123
123
  static async run({ config, options, manifest, additional }) {
124
124
  try {
125
- log.info("Kick start app..." + os.platform() + " " + os.arch());
125
+ log?.info("Kick start app..." + os.platform() + " " + os.arch());
126
126
  ADDS.init(additional);
127
127
  const initSequence = new InitSequence(STANDART_INIT_SEQUENCE);
128
128
  await ADDS.run("pre", {
@@ -159,8 +159,8 @@ class Init {
159
159
  }
160
160
 
161
161
  static throwError(errMsg = "Fatal error", errCode = 1) {
162
- log.error(errMsg);
163
- log.log(`Exit process...with code ${errCode}`);
162
+ log?.error(errMsg);
163
+ log?.log(`Exit process...with code ${errCode}`);
164
164
  throw new Error(errMsg);
165
165
  }
166
166
  }
@@ -3,7 +3,7 @@ const ENV = process.env.NODE_ENV || "development";
3
3
  const path = require("path");
4
4
  const logger = require("not-log");
5
5
  const log = logger(module, "not-node//init//app");
6
- const { notErrorReporter } = require("not-error");
6
+ const { notErrorReporter } = require("not-error/src/index.cjs");
7
7
 
8
8
  const CONST_CORE_PATH = path.join(__dirname, "../../core");
9
9
 
@@ -21,23 +21,7 @@ module.exports = class InitApp {
21
21
 
22
22
  static async setAppEnvs({ config, options, master, emit }) {
23
23
  await emit("app.setEnv.pre", { config, options, master });
24
- master.setEnv("validationEnv", options.validationEnv);
25
- master.setEnv("hostname", config.get("hostname"));
26
- master.setEnv("server", `https://` + config.get("host"));
27
- master.setEnv(
28
- "appPath",
29
- master.getAbsolutePath(config.get("path.app"))
30
- );
31
- master.setEnv(
32
- "dbDumpsPath",
33
- master.getAbsolutePath(config.get("path.dbDumps"))
34
- );
35
- master.setEnv(
36
- "tmpPath",
37
- master.getAbsolutePath(config.get("path.tmp"))
38
- );
39
24
  master.setEnv("name", master.getManifest().name);
40
- master.setEnv("fullServerName", config.get("fullServerName"));
41
25
  master.setEnv(
42
26
  "rolesPriority",
43
27
  master.getManifest().targets.server.roles
@@ -79,7 +63,7 @@ module.exports = class InitApp {
79
63
 
80
64
  async run({ config, options, master, emit }) {
81
65
  try {
82
- log.info("Init not-app...");
66
+ log?.info("Init not-app...");
83
67
  await emit("app.pre", { config, options, master });
84
68
  await InitApp.createApp({ config, options, master, emit });
85
69
  await InitApp.setAppEnvs({ config, options, master, emit });
@@ -1,6 +1,6 @@
1
1
  const log = require("not-log")(module, "not-node//init//env");
2
2
  const { tryDirAsync } = require("../../common");
3
- const notEnv = require("../../env");
3
+
4
4
  const {
5
5
  DEFAULT_PATH_WS,
6
6
  DEFAULT_PATH_MODULES,
@@ -60,25 +60,37 @@ module.exports = class InitENV {
60
60
  static async checkPaths(master, config) {
61
61
  const paths = config.get("path");
62
62
  if (paths) {
63
+ log?.log("Paths existence check");
63
64
  for (let pathName of Object.keys(paths)) {
64
- if (await tryDirAsync(paths[pathName])) {
65
- log?.error(
66
- `config path (${pathName}) not exists: ${paths[pathName]}`
67
- );
65
+ const absolutePath = master.getEnv(`${pathName}Path`);
66
+ if (absolutePath) {
67
+ if (!(await tryDirAsync(absolutePath))) {
68
+ log?.error(
69
+ `config path (${pathName}) not exists: ${paths[pathName]} - ${absolutePath}`
70
+ );
71
+ } else {
72
+ log?.log(
73
+ `config path (${pathName}) exists: ${paths[pathName]} - ${absolutePath}`
74
+ );
75
+ }
68
76
  }
69
77
  }
70
78
  }
71
79
  }
72
80
 
73
- static addToEnv(key, val) {
74
- notEnv.set(key, val);
81
+ static addToEnv(master, key, val) {
82
+ master.setEnv(key, val);
75
83
  return val;
76
84
  }
77
85
 
78
86
  static setObsoleteAndNew({ config, master, from, to, def }) {
79
87
  config.set(
80
88
  to,
81
- InitENV.addToEnv(to, master.getAbsolutePath(config.get(from, def))),
89
+ InitENV.addToEnv(
90
+ master,
91
+ to,
92
+ master.getAbsolutePath(config.get(from, def))
93
+ ),
82
94
  `obsolete: use notEnv.get('${to}') instead`
83
95
  );
84
96
  }
@@ -97,23 +109,28 @@ module.exports = class InitENV {
97
109
  log?.info("Setting up server environment variables...");
98
110
  await emit("env.pre", { config, options, master });
99
111
 
112
+ master.setEnv("validationEnv", options.validationEnv);
113
+ master.setEnv("hostname", config.get("hostname"));
114
+ master.setEnv("server", `https://` + config.get("host"));
115
+
100
116
  InitENV.initFromTemplate({ config, master });
101
117
 
102
118
  config.set(
103
119
  "appPath",
104
- InitENV.addToEnv("appPath", options.pathToApp),
120
+ InitENV.addToEnv(master, "appPath", options.pathToApp),
105
121
  "obsolete: use notEnv.get('appPath')"
106
122
  );
107
123
 
108
124
  config.set(
109
125
  "npmPath",
110
- InitENV.addToEnv("npmPath", options.pathToNPM),
126
+ InitENV.addToEnv(master, "npmPath", options.pathToNPM),
111
127
  "obsolete: use notEnv.get('npmPath')"
112
128
  );
113
129
 
114
130
  config.set(
115
131
  "fullServerName",
116
132
  InitENV.addToEnv(
133
+ master,
117
134
  "fullServerName",
118
135
  InitENV.getFullServerName(config)
119
136
  ),
package/test/init/env.js CHANGED
@@ -78,6 +78,7 @@ module.exports = ({ expect }) => {
78
78
  getAbsolutePath(str) {
79
79
  return str + "_fake_absolute";
80
80
  },
81
+ setEnv() {},
81
82
  };
82
83
  const options = {
83
84
  pathToApp: "pathToApp__fake",
@@ -108,6 +109,7 @@ module.exports = ({ expect }) => {
108
109
  getAbsolutePath(str) {
109
110
  return str + "_fake_absolute";
110
111
  },
112
+ setEnv() {},
111
113
  };
112
114
  const options = {
113
115
  pathToApp: "pathToApp__fake",