not-node 6.3.72 → 6.3.73
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/init/lib/env.js +68 -29
package/package.json
CHANGED
package/src/init/lib/env.js
CHANGED
|
@@ -1,5 +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
|
const {
|
|
4
5
|
DEFAULT_PATH_WS,
|
|
5
6
|
DEFAULT_PATH_MODULES,
|
|
@@ -9,6 +10,34 @@ const {
|
|
|
9
10
|
} = require("../../const");
|
|
10
11
|
|
|
11
12
|
module.exports = class InitENV {
|
|
13
|
+
static CONFIG_SET = [
|
|
14
|
+
{
|
|
15
|
+
from: "path:static",
|
|
16
|
+
to: "staticPath",
|
|
17
|
+
def: DEFAULT_PATH_STATIC,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
from: "path:modules",
|
|
21
|
+
to: "modulesPath",
|
|
22
|
+
def: DEFAULT_PATH_MODULES,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
from: "path:tmp",
|
|
26
|
+
to: "tmpPath",
|
|
27
|
+
def: DEFAULT_PATH_TMP,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
from: "path:dbDumps",
|
|
31
|
+
to: "dbDumpsPath",
|
|
32
|
+
def: DEFAULT_PATH_DB_DUMPS,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
from: "path:ws",
|
|
36
|
+
to: "wsPath",
|
|
37
|
+
def: DEFAULT_PATH_WS,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
12
41
|
static getProxyPort(config) {
|
|
13
42
|
return parseInt(config.get("proxy:port") || config.get("port"));
|
|
14
43
|
}
|
|
@@ -41,46 +70,56 @@ module.exports = class InitENV {
|
|
|
41
70
|
}
|
|
42
71
|
}
|
|
43
72
|
|
|
73
|
+
static addToEnv(key, val) {
|
|
74
|
+
notEnv.setEnv(key, val);
|
|
75
|
+
return val;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static setObsoleteAndNew({ config, master, from, to, def }) {
|
|
79
|
+
config.set(
|
|
80
|
+
to,
|
|
81
|
+
InitENV.addToEnv(to, master.getAbsolutePath(config.get(from, def))),
|
|
82
|
+
`obsolete: use notEnv.getEnv('${to}') instead`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static initFromTemplate({ config, master }) {
|
|
87
|
+
InitENV.CONFIG_SET.forEach((item) => {
|
|
88
|
+
InitENV.setObsoleteAndNew({
|
|
89
|
+
config,
|
|
90
|
+
master,
|
|
91
|
+
...item,
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
44
96
|
async run({ config, options, master, emit }) {
|
|
45
97
|
log?.info("Setting up server environment variables...");
|
|
46
98
|
await emit("env.pre", { config, options, master });
|
|
99
|
+
|
|
100
|
+
InitENV.initFromTemplate({ config, master });
|
|
101
|
+
|
|
47
102
|
config.set(
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
config.set(
|
|
54
|
-
"modulesPath",
|
|
55
|
-
master.getAbsolutePath(
|
|
56
|
-
config.get("path:modules", DEFAULT_PATH_MODULES)
|
|
57
|
-
)
|
|
103
|
+
"appPath",
|
|
104
|
+
InitENV.addToEnv("appPath", options.pathToApp),
|
|
105
|
+
"obsolete: use notEnv.getEnv('appPath')"
|
|
58
106
|
);
|
|
59
107
|
|
|
60
108
|
config.set(
|
|
61
|
-
"
|
|
62
|
-
|
|
109
|
+
"npmPath",
|
|
110
|
+
InitENV.addToEnv("npmPath", options.pathToNPM),
|
|
111
|
+
"obsolete: use notEnv.getEnv('npmPath')"
|
|
63
112
|
);
|
|
64
113
|
|
|
65
114
|
config.set(
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
115
|
+
"fullServerName",
|
|
116
|
+
InitENV.addToEnv(
|
|
117
|
+
"fullServerName",
|
|
118
|
+
InitENV.getFullServerName(config)
|
|
119
|
+
),
|
|
120
|
+
"obsolete: use notEnv.getEnv('fullServerName')"
|
|
70
121
|
);
|
|
71
|
-
|
|
72
|
-
config.set("npmPath", options.pathToNPM);
|
|
73
|
-
config.set("fullServerName", InitENV.getFullServerName(config));
|
|
74
|
-
if (config.get("path:ws")) {
|
|
75
|
-
log?.log(
|
|
76
|
-
"wsPath",
|
|
77
|
-
master.getAbsolutePath(config.get("path:ws", DEFAULT_PATH_WS))
|
|
78
|
-
);
|
|
79
|
-
config.set(
|
|
80
|
-
"wsPath",
|
|
81
|
-
master.getAbsolutePath(config.get("path:ws", DEFAULT_PATH_WS))
|
|
82
|
-
);
|
|
83
|
-
}
|
|
122
|
+
|
|
84
123
|
await InitENV.checkPaths(master, config);
|
|
85
124
|
await emit("env.post", { config, options, master });
|
|
86
125
|
}
|