not-node 6.3.75 → 6.3.77

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.75",
3
+ "version": "6.3.77",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
  }
@@ -38,10 +38,10 @@ module.exports = class InitApp {
38
38
 
39
39
  static async importModules({ config, options, master, emit }) {
40
40
  await emit("app.importModules.pre", { config, options, master });
41
- master.getApp().importModulesFrom(config.get("modulesPath"));
41
+ master.getApp().importModulesFrom(master.getEnv("modulesPath"));
42
42
  if (Array.isArray(config.get("importModulesFromNPM"))) {
43
43
  config.get("importModulesFromNPM").forEach((modName) => {
44
- const modPath = path.join(config.get("npmPath"), modName);
44
+ const modPath = path.join(master.getEnv("npmPath"), modName);
45
45
  master.getApp().importModuleFrom(modPath, modName);
46
46
  });
47
47
  }
@@ -63,13 +63,13 @@ module.exports = class InitApp {
63
63
 
64
64
  async run({ config, options, master, emit }) {
65
65
  try {
66
- log.info("Init not-app...");
66
+ log?.info("Init not-app...");
67
67
  await emit("app.pre", { config, options, master });
68
68
  await InitApp.createApp({ config, options, master, emit });
69
69
  await InitApp.setAppEnvs({ config, options, master, emit });
70
70
  await InitApp.initCore({ config, options, master, emit });
71
71
  await InitApp.importModules({ config, options, master, emit });
72
- await InitApp.createReporter({ config, options, master, emit });
72
+ await InitApp.createReporter({ config, master });
73
73
  await emit("app.post", { config, options, master });
74
74
  } catch (e) {
75
75
  master.throwError(e.message, 1);
@@ -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
  }
@@ -105,19 +117,20 @@ module.exports = class InitENV {
105
117
 
106
118
  config.set(
107
119
  "appPath",
108
- InitENV.addToEnv("appPath", options.pathToApp),
120
+ InitENV.addToEnv(master, "appPath", options.pathToApp),
109
121
  "obsolete: use notEnv.get('appPath')"
110
122
  );
111
123
 
112
124
  config.set(
113
125
  "npmPath",
114
- InitENV.addToEnv("npmPath", options.pathToNPM),
126
+ InitENV.addToEnv(master, "npmPath", options.pathToNPM),
115
127
  "obsolete: use notEnv.get('npmPath')"
116
128
  );
117
129
 
118
130
  config.set(
119
131
  "fullServerName",
120
132
  InitENV.addToEnv(
133
+ master,
121
134
  "fullServerName",
122
135
  InitENV.getFullServerName(config)
123
136
  ),
package/test/init/app.js CHANGED
@@ -205,6 +205,9 @@ module.exports = ({ expect }) => {
205
205
  getManifest() {
206
206
  return fakeManifest;
207
207
  },
208
+ getEnv(name) {
209
+ return `${name}_fake`;
210
+ },
208
211
  };
209
212
 
210
213
  await InitApp.importModules({
@@ -256,6 +259,9 @@ module.exports = ({ expect }) => {
256
259
  getManifest() {
257
260
  return fakeManifest;
258
261
  },
262
+ getEnv(name) {
263
+ return `${name}_fake`;
264
+ },
259
265
  };
260
266
  await InitApp.importModules({
261
267
  master,
@@ -400,6 +406,13 @@ module.exports = ({ expect }) => {
400
406
  };
401
407
  const master = {
402
408
  setEnv() {},
409
+ getEnv: (str) => {
410
+ if (str === "importModulesFromNPM") {
411
+ return ["fakeMod", "fakeMod2"];
412
+ } else {
413
+ return str + "_fake";
414
+ }
415
+ },
403
416
  setApp(app) {
404
417
  expect(app).to.be.instanceof(FakeApp);
405
418
  },