not-node 6.5.40 → 6.5.42
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 +27 -16
- package/package.json +1 -1
- package/src/cli/actions/project.mjs +17 -6
- package/src/cli/lib/fs.mjs +34 -12
- package/src/cli/lib/module.server.mjs +2 -2
- package/src/cli/lib/opts.mjs +7 -8
- package/src/init/lib/sessions/redis.js +1 -1
- package/tmpl/dirs/front.mjs +11 -7
- package/tmpl/files/app/package.ejs +5 -3
- package/tmpl/files/app/project.manifest.ejs +5 -5
package/bin/not-builder.js
CHANGED
|
@@ -690,23 +690,34 @@ async function build_Server(pathToRoot, roles, targetName, targetManifest) {
|
|
|
690
690
|
console.log("config path", configName);
|
|
691
691
|
config = lib.getConfReader(configName);
|
|
692
692
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
693
|
+
async function render() {
|
|
694
|
+
//searchig for targets
|
|
695
|
+
if (
|
|
696
|
+
config.get("targets") &&
|
|
697
|
+
Object.keys(config.get("targets")).length > 0
|
|
698
|
+
) {
|
|
699
|
+
//cycling through targets
|
|
700
|
+
for (let target in config.get("targets")) {
|
|
701
|
+
let targetConfig = config.get("targets")[target];
|
|
702
|
+
if (targetConfig && targetConfig.builder) {
|
|
703
|
+
//if target type is server
|
|
704
|
+
switch (targetConfig.builder) {
|
|
705
|
+
case "server":
|
|
706
|
+
await build_Server(
|
|
707
|
+
path.dirname(configName),
|
|
708
|
+
targetConfig.roles,
|
|
709
|
+
target,
|
|
710
|
+
targetConfig
|
|
711
|
+
);
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
709
714
|
}
|
|
710
715
|
}
|
|
711
716
|
}
|
|
712
717
|
}
|
|
718
|
+
|
|
719
|
+
render()
|
|
720
|
+
.then(() => {
|
|
721
|
+
process.exit(0);
|
|
722
|
+
})
|
|
723
|
+
.catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAbsolute, resolve } from "node:path";
|
|
1
|
+
import { isAbsolute, resolve, join } from "node:path";
|
|
2
2
|
|
|
3
3
|
import { Option } from "commander";
|
|
4
4
|
import inquirer from "inquirer";
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
makeScriptExecutable,
|
|
11
11
|
installPackages,
|
|
12
12
|
buildClientSideScripts,
|
|
13
|
+
findAllFields,
|
|
13
14
|
} from "../lib/fs.mjs";
|
|
14
15
|
|
|
15
16
|
import { postStartupInstructions } from "../lib/messages.mjs";
|
|
@@ -77,6 +78,7 @@ export default (program, { CWD }) => {
|
|
|
77
78
|
console.log("creating site in", siteDir);
|
|
78
79
|
const ProjectConfig = {
|
|
79
80
|
path: dir,
|
|
81
|
+
sitePath: siteDir,
|
|
80
82
|
};
|
|
81
83
|
//
|
|
82
84
|
ProjectConfig.AppName = await Readers.AppName(
|
|
@@ -122,16 +124,25 @@ export default (program, { CWD }) => {
|
|
|
122
124
|
await createDir(dir);
|
|
123
125
|
await createDirContent(dir, ProjectStructure, ProjectConfig);
|
|
124
126
|
await createProjectToolsAndConfigs(dir, ProjectConfig);
|
|
125
|
-
const PATH_MODULES_SERVER =
|
|
126
|
-
|
|
127
|
+
const PATH_MODULES_SERVER = join(
|
|
128
|
+
ProjectConfig.sitePath,
|
|
127
129
|
Options.DEFAULT_SERVER_MODULES_SUB_PATH
|
|
128
130
|
);
|
|
129
|
-
const PATH_MODULES_FRONT =
|
|
130
|
-
|
|
131
|
+
const PATH_MODULES_FRONT = join(
|
|
132
|
+
ProjectConfig.sitePath,
|
|
131
133
|
Options.DEFAULT_FRONT_MODULES_SUB_PATH
|
|
132
134
|
);
|
|
135
|
+
const modulesDir = join(
|
|
136
|
+
siteDir,
|
|
137
|
+
Options.DEFAULT_SERVER_MODULES_SUB_PATH
|
|
138
|
+
);
|
|
139
|
+
const allFields = await findAllFields(dir, modulesDir);
|
|
133
140
|
while (await Readers.isUserNeedCreateServerModule(inquirer)) {
|
|
134
|
-
await createServerModule(
|
|
141
|
+
await createServerModule(
|
|
142
|
+
PATH_MODULES_SERVER,
|
|
143
|
+
ProjectConfig,
|
|
144
|
+
allFields
|
|
145
|
+
);
|
|
135
146
|
}
|
|
136
147
|
if (await Readers.isUserNeedFrontModuleBootstrap(inquirer)) {
|
|
137
148
|
await createBootstrapFrontModule(
|
package/src/cli/lib/fs.mjs
CHANGED
|
@@ -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
|
}
|
|
@@ -136,7 +136,7 @@ function makeScriptExecutable(pathToTargetScript) {
|
|
|
136
136
|
});
|
|
137
137
|
npmInstall.on("exit", (code) => {
|
|
138
138
|
if (code == 0) {
|
|
139
|
-
resolve();
|
|
139
|
+
resolve(true);
|
|
140
140
|
} else {
|
|
141
141
|
reject(`chmod +x ${pathToTargetScript} ${code}`);
|
|
142
142
|
}
|
|
@@ -156,7 +156,7 @@ function installPackages(siteDir) {
|
|
|
156
156
|
});
|
|
157
157
|
npmInstall.on("exit", (code) => {
|
|
158
158
|
if (code == 0) {
|
|
159
|
-
resolve();
|
|
159
|
+
resolve(true);
|
|
160
160
|
} else {
|
|
161
161
|
reject(`NPM install exited with code ${code}`);
|
|
162
162
|
}
|
|
@@ -171,12 +171,16 @@ function buildClientSideScripts(siteDir) {
|
|
|
171
171
|
cwd: siteDir,
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
+
npmInstall.stdout.on("data", (data) => {
|
|
175
|
+
Logger.log(data.toString());
|
|
176
|
+
});
|
|
177
|
+
|
|
174
178
|
npmInstall.stderr.on("data", (data) => {
|
|
175
179
|
Logger.error(data.toString());
|
|
176
180
|
});
|
|
177
181
|
npmInstall.on("exit", (code) => {
|
|
178
182
|
if (code == 0) {
|
|
179
|
-
resolve();
|
|
183
|
+
resolve(true);
|
|
180
184
|
} else {
|
|
181
185
|
reject(`npm run build job exited with code ${code}`);
|
|
182
186
|
}
|
|
@@ -240,7 +244,7 @@ async function findAllFieldsInModules(modulesDirPath) {
|
|
|
240
244
|
const modulesNames = await readdir(modulesDirPath);
|
|
241
245
|
const result = [];
|
|
242
246
|
for (const moduleName of modulesNames) {
|
|
243
|
-
if (moduleName && moduleName.indexOf("not-") === 0) {
|
|
247
|
+
if (moduleName && moduleName.indexOf("not-") === 0) {
|
|
244
248
|
const listOfFieldsInModule = await findFieldsInModule(
|
|
245
249
|
join(modulesDirPath, moduleName)
|
|
246
250
|
);
|
|
@@ -253,7 +257,7 @@ async function findAllFieldsInModules(modulesDirPath) {
|
|
|
253
257
|
fullName: `${moduleName}//${fieldName}`,
|
|
254
258
|
};
|
|
255
259
|
}
|
|
256
|
-
);
|
|
260
|
+
);
|
|
257
261
|
result.push(...listOfFieldsDescriptions);
|
|
258
262
|
}
|
|
259
263
|
}
|
|
@@ -265,18 +269,36 @@ async function findAllFieldsInModules(modulesDirPath) {
|
|
|
265
269
|
}
|
|
266
270
|
}
|
|
267
271
|
|
|
268
|
-
async function
|
|
272
|
+
async function findAllFieldsInGlobalNodeModules() {
|
|
273
|
+
const result = [];
|
|
274
|
+
for (let globalLib of Options.DEFAULT_GLOBAL_NPM_LIB) {
|
|
275
|
+
const dirname = join(globalLib, "node_modules");
|
|
276
|
+
try {
|
|
277
|
+
result.push(...(await findAllFieldsInModules(dirname)));
|
|
278
|
+
} catch {
|
|
279
|
+
Logger.log("No fields in ", dirname);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function findAllFieldsInLocalNodeModules(siteDirPath) {
|
|
269
286
|
const dirname = join(siteDirPath, "node_modules");
|
|
270
287
|
return await findAllFieldsInModules(dirname);
|
|
271
288
|
}
|
|
272
289
|
|
|
273
290
|
async function findAllFields(siteDirPath, modulesDir) {
|
|
274
291
|
try {
|
|
275
|
-
const
|
|
292
|
+
const fieldsInGlobalNodeModules =
|
|
293
|
+
await findAllFieldsInGlobalNodeModules();
|
|
294
|
+
const fieldsInLocalNodeModules = await findAllFieldsInLocalNodeModules(
|
|
276
295
|
siteDirPath
|
|
277
296
|
);
|
|
278
297
|
const fieldsInProjectModules = await findAllFieldsInModules(modulesDir);
|
|
279
|
-
|
|
298
|
+
const fromNPM = fieldsInLocalNodeModules.length
|
|
299
|
+
? fieldsInLocalNodeModules
|
|
300
|
+
: fieldsInGlobalNodeModules;
|
|
301
|
+
return [...fromNPM, ...fieldsInProjectModules];
|
|
280
302
|
} catch (err) {
|
|
281
303
|
console.error(err);
|
|
282
304
|
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);
|
|
@@ -89,7 +89,7 @@ async function createServerModule(modules_dir, config, availableFields) {
|
|
|
89
89
|
availableFields,
|
|
90
90
|
};
|
|
91
91
|
await createDir(moduleDir);
|
|
92
|
-
|
|
92
|
+
console.log(JSON.stringify(moduleConfig, null, 4));
|
|
93
93
|
await createDirContent(
|
|
94
94
|
moduleDir,
|
|
95
95
|
ProjectSubStructures["module.server"],
|
package/src/cli/lib/opts.mjs
CHANGED
|
@@ -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;
|
|
@@ -11,18 +16,12 @@ class Options {
|
|
|
11
16
|
|
|
12
17
|
#DEFAULT_SERVER_MODULES_SUB_PATH = "./app/server/modules";
|
|
13
18
|
get DEFAULT_SERVER_MODULES_SUB_PATH() {
|
|
14
|
-
return
|
|
15
|
-
this.DEFAULT_SITE_PATH,
|
|
16
|
-
this.#DEFAULT_SERVER_MODULES_SUB_PATH
|
|
17
|
-
);
|
|
19
|
+
return this.#DEFAULT_SERVER_MODULES_SUB_PATH;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
#DEFAULT_FRONT_MODULES_SUB_PATH = "./app/front/src";
|
|
21
23
|
get DEFAULT_FRONT_MODULES_SUB_PATH() {
|
|
22
|
-
return
|
|
23
|
-
this.DEFAULT_SITE_PATH,
|
|
24
|
-
this.#DEFAULT_FRONT_MODULES_SUB_PATH
|
|
25
|
-
);
|
|
24
|
+
return this.#DEFAULT_FRONT_MODULES_SUB_PATH;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
#PATH_TMPL = resolve(__dirname, "../../../tmpl/files");
|
|
@@ -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
|
|
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);
|
package/tmpl/dirs/front.mjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
build: {},
|
|
3
3
|
src: {},
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
tmpl: {
|
|
5
|
+
content: {
|
|
6
|
+
"index.!.js": {
|
|
7
|
+
tmpl: "app/front/index.!.ejs",
|
|
8
|
+
args: ["not_node_reporter"],
|
|
9
|
+
},
|
|
10
|
+
"rollup.!.js": {
|
|
11
|
+
tmpl: "app/front/rollup.!.ejs",
|
|
12
|
+
args: [],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
11
15
|
},
|
|
12
16
|
"build.env.js": {
|
|
13
17
|
tmpl: "app/front/build.env.ejs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"redis": "*",
|
|
33
33
|
"pug":"*",
|
|
34
|
-
"not-node": "*",
|
|
34
|
+
"not-node": "*",
|
|
35
35
|
<% for(let moduleName of modules){ %>"<%- moduleName %>":"*",
|
|
36
36
|
<% } %>
|
|
37
37
|
"dotenv": "*"
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
"@rollup/plugin-commonjs": "^22.0.1",
|
|
46
46
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
47
47
|
"@rollup/plugin-json": "^4.1.0",
|
|
48
|
+
"@babel/plugin-proposal-class-properties": "*",
|
|
49
|
+
"@babel/plugin-proposal-private-methods" : "*",
|
|
48
50
|
"babel-core": "*",
|
|
49
51
|
"babel-polyfill": "*",
|
|
50
52
|
"babel-preset-es2015-rollup": "*",
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"ink-docstrap": "^1.3.2",
|
|
55
57
|
"jsdoc": "^3.6.11",
|
|
56
58
|
"mocha": "^10.0.0",
|
|
57
|
-
"ndb": "^1.1.5",
|
|
59
|
+
"ndb": "^1.1.5",
|
|
58
60
|
"nyc": "^15.1.0",
|
|
59
61
|
"rollup": "^2.77.2",
|
|
60
62
|
"rollup-plugin-postcss": "^4.0.2",
|
|
@@ -68,4 +70,4 @@
|
|
|
68
70
|
"svelte": "*",
|
|
69
71
|
"yargs": "^17.5.1"
|
|
70
72
|
}
|
|
71
|
-
}
|
|
73
|
+
}
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
"name": "<%- AppName %>",
|
|
6
6
|
"roles": [<% roles.forEach(function(role, index){ %>"<%- role %>"<%- (roles.length - 1 > index)?',':'' %><% }); %>],
|
|
7
7
|
"builder": "server",
|
|
8
|
-
"root": "app/front/",
|
|
9
|
-
"src": "app/front/",
|
|
8
|
+
"root": "app/front/tmpl",
|
|
9
|
+
"src": "app/front/tmpl",
|
|
10
10
|
"build": "app/front/build/",
|
|
11
|
-
"index": "app/front/index.!.
|
|
12
|
-
"rollup": "app/front/rollup.!.
|
|
11
|
+
"index": "app/front/tmpl/index.!.mjs",
|
|
12
|
+
"rollup": "app/front/tmpl/rollup.!.mjs",
|
|
13
13
|
"modules": {
|
|
14
14
|
"serverModulesDir": "app/server/modules",
|
|
15
15
|
"frontModulesDir": "app/front/src",
|
|
16
16
|
"npm": {
|
|
17
17
|
<% modules.forEach(function(module, index){ %>"<%- module %>": {}<%- (modules.length - 1 > index)?',':'' %>
|
|
18
|
-
<% }); %>
|
|
18
|
+
<% }); %>
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|