not-node 6.0.8 → 6.1.0
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 +6 -8
- package/bin/not-cli.mjs +369 -0
- package/index.js +6 -0
- package/package.json +133 -128
- package/playground/.babelrc +11 -0
- package/playground/.eslintignore +4 -0
- package/playground/.eslintrc.json +23 -0
- package/playground/app/front/index.!.js +64 -0
- package/playground/app/front/rollup.!.js +70 -0
- package/playground/app/front/src/admin/main/index.js +45 -0
- package/playground/app/front/src/client/main/index.js +45 -0
- package/playground/app/front/src/common/index.js +39 -0
- package/playground/app/front/src/common/ncInit.js +18 -0
- package/playground/app/front/src/common/ws.client.main.js +35 -0
- package/playground/app/front/src/guest/main/index.js +34 -0
- package/playground/app/front/src/root/main/index.js +45 -0
- package/playground/app/front/src/user/main/index.js +45 -0
- package/playground/app/server/app.js +22 -0
- package/playground/app/server/config/common.json +53 -0
- package/playground/app/server/config/development.json +34 -0
- package/playground/app/server/config/production.json +34 -0
- package/playground/app/server/config/stage.json +34 -0
- package/playground/app/server/index.js +20 -0
- package/playground/app/server/routes/index.js +36 -0
- package/playground/app/server/routes/site.js +71 -0
- package/playground/app/server/views/admin/foot.pug +1 -0
- package/playground/app/server/views/admin/head.pug +7 -0
- package/playground/app/server/views/admin/menu.pug +2 -0
- package/playground/app/server/views/admin.pug +19 -0
- package/playground/app/server/views/dashboard.pug +20 -0
- package/playground/app/server/views/index.pug +15 -0
- package/playground/app/server/views/parts/header.android.pug +7 -0
- package/playground/app/server/views/parts/header.ios.pug +5 -0
- package/playground/app/server/views/parts/header.pug +18 -0
- package/playground/app/server/views/parts/menu.pug +1 -0
- package/playground/app/server/views/parts/overview.pug +2 -0
- package/playground/app/server/ws/auth.js +41 -0
- package/playground/app/server/ws/index.js +84 -0
- package/playground/bin/build.sh +8 -0
- package/playground/package.json +66 -0
- package/playground/project.manifest.json +34 -0
- package/src/app.js +3 -3
- package/src/cli/const.mjs +71 -0
- package/src/cli/readers/AppDescription.mjs +14 -0
- package/src/cli/readers/AppName.mjs +14 -0
- package/src/cli/readers/ModelName.mjs +14 -0
- package/src/cli/readers/ModuleName.mjs +14 -0
- package/src/cli/readers/actions.mjs +25 -0
- package/src/cli/readers/appName.mjs +14 -0
- package/src/cli/readers/cors.mjs +12 -0
- package/src/cli/readers/db/ioredis.mjs +3 -0
- package/src/cli/readers/db/mongoose.mjs +61 -0
- package/src/cli/readers/db/redis.mjs +3 -0
- package/src/cli/readers/db.mjs +30 -0
- package/src/cli/readers/entityData.mjs +44 -0
- package/src/cli/readers/entityLayers.mjs +21 -0
- package/src/cli/readers/fields.mjs +13 -0
- package/src/cli/readers/filter.mjs +34 -0
- package/src/cli/readers/hostname.mjs +23 -0
- package/src/cli/readers/index.mjs +86 -0
- package/src/cli/readers/init_root_user.mjs +55 -0
- package/src/cli/readers/isUserNeedCreateEntity.mjs +14 -0
- package/src/cli/readers/isUserNeedCreateServerModule.mjs +14 -0
- package/src/cli/readers/isUserNeedFrontModuleBootstrap.mjs +14 -0
- package/src/cli/readers/modelIncrement.mjs +32 -0
- package/src/cli/readers/modelIncrementFilter.mjs +49 -0
- package/src/cli/readers/modelOptions.mjs +61 -0
- package/src/cli/readers/modelValidators.mjs +14 -0
- package/src/cli/readers/modelVersioning.mjs +14 -0
- package/src/cli/readers/moduleLayers.mjs +25 -0
- package/src/cli/readers/modules.mjs +19 -0
- package/src/cli/readers/not_node_monitor.mjs +48 -0
- package/src/cli/readers/not_node_reporter.mjs +42 -0
- package/src/cli/readers/port.mjs +14 -0
- package/src/cli/readers/roles.mjs +25 -0
- package/src/cli/readers/rolesSecondary.mjs +14 -0
- package/src/cli/readers/secret.mjs +21 -0
- package/src/cli/readers/session.mjs +55 -0
- package/src/cli/readers/ssl.mjs +38 -0
- package/src/cli/readers/user.mjs +62 -0
- package/src/cli/readers/ws.mjs +35 -0
- package/src/cli/renderers/controllers.mjs +26 -0
- package/src/cli/renderers/controllersCommons.mjs +42 -0
- package/src/cli/renderers/controllersIndex.mjs +18 -0
- package/src/cli/renderers/fields.mjs +1 -0
- package/src/cli/renderers/forms.mjs +43 -0
- package/src/cli/renderers/frontModuleGuestMain.mjs +10 -0
- package/src/cli/renderers/frontModuleRoleMain.mjs +10 -0
- package/src/cli/renderers/index.mjs +29 -0
- package/src/cli/renderers/logics.mjs +17 -0
- package/src/cli/renderers/models.mjs +16 -0
- package/src/cli/renderers/routes.mjs +31 -0
- package/src/domain.js +8 -9
- package/src/headers.js +17 -0
- package/src/init/index.js +1 -0
- package/src/init/lib/app.js +5 -7
- package/src/init/lib/modules.js +2 -1
- package/src/init/lib/routes.js +1 -0
- package/src/manifest/module.js +6 -20
- package/src/metas.js +34 -0
- package/src/styler.js +38 -0
- package/tmpl/dirs/app.mjs +32 -0
- package/tmpl/dirs/front.mjs +12 -0
- package/tmpl/dirs/module.front.mjs +19 -0
- package/tmpl/dirs/module.server.controllers.common.mjs +7 -0
- package/tmpl/dirs/module.server.mjs +14 -0
- package/tmpl/dirs/server.mjs +127 -0
- package/tmpl/dirs/static.mjs +9 -0
- package/tmpl/files/app/.babelrc +11 -0
- package/tmpl/files/app/.eslintignore +4 -0
- package/tmpl/files/app/.eslintrc.json +23 -0
- package/tmpl/files/app/app.ejs +22 -0
- package/tmpl/files/app/build.sh +8 -0
- package/tmpl/files/app/config/common.ejs +131 -0
- package/tmpl/files/app/config/other.ejs +34 -0
- package/tmpl/files/app/deploy.pm2.ejs +23 -0
- package/tmpl/files/app/env.ejs +16 -0
- package/tmpl/files/app/front/build.env.ejs +7 -0
- package/tmpl/files/app/front/index.!.ejs +66 -0
- package/tmpl/files/app/front/rollup.!.ejs +70 -0
- package/tmpl/files/app/index.ejs +20 -0
- package/tmpl/files/app/package.ejs +66 -0
- package/tmpl/files/app/project.manifest.ejs +23 -0
- package/tmpl/files/app/routes/index.ejs +36 -0
- package/tmpl/files/app/routes/site.ejs +71 -0
- package/tmpl/files/app/views/admin/foot.ejs +1 -0
- package/tmpl/files/app/views/admin/head.ejs +7 -0
- package/tmpl/files/app/views/admin/menu.ejs +2 -0
- package/tmpl/files/app/views/admin.ejs +19 -0
- package/tmpl/files/app/views/dashboard.ejs +20 -0
- package/tmpl/files/app/views/index.ejs +15 -0
- package/tmpl/files/app/views/parts/header.android.ejs +7 -0
- package/tmpl/files/app/views/parts/header.ejs +18 -0
- package/tmpl/files/app/views/parts/header.ios.ejs +5 -0
- package/tmpl/files/app/views/parts/menu.ejs +1 -0
- package/tmpl/files/app/views/parts/overview.ejs +2 -0
- package/tmpl/files/app/ws/auth.ejs +41 -0
- package/tmpl/files/app/ws/index.ejs +84 -0
- package/tmpl/files/module.front/common/index.ejs +39 -0
- package/tmpl/files/module.front/common/ncInit.ejs +18 -0
- package/tmpl/files/module.front/common/ws.client.main.ejs +35 -0
- package/tmpl/files/module.front/role/guest.index.ejs +45 -0
- package/tmpl/files/module.front/role/index.ejs +34 -0
- package/tmpl/files/module.server/const.ejs +1 -0
- package/{scaffold/base.js → tmpl/files/module.server/extractor.ejs} +0 -0
- package/tmpl/files/module.server/index.ejs +8 -0
- package/tmpl/files/module.server/layers/controllers/common/crud.ejs +95 -0
- package/tmpl/files/module.server/layers/controllers/common/index.ejs +59 -0
- package/tmpl/files/module.server/layers/controllers/common/validators.ejs +44 -0
- package/tmpl/files/module.server/layers/controllers/common/ws.client.ejs +25 -0
- package/tmpl/files/module.server/layers/controllers/role/crud.ejs +11 -0
- package/tmpl/files/module.server/layers/controllers/role/index.ejs +29 -0
- package/tmpl/files/module.server/layers/fields.ejs +30 -0
- package/tmpl/files/module.server/layers/forms/_data.ejs +35 -0
- package/tmpl/files/module.server/layers/forms/create.ejs +47 -0
- package/tmpl/files/module.server/layers/forms/delete.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/get.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/getRaw.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/listAll.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/listAndCount.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/update.ejs +40 -0
- package/tmpl/files/module.server/layers/forms/validator.ejs +32 -0
- package/tmpl/files/module.server/layers/forms.ejs +49 -0
- package/tmpl/files/module.server/layers/locales.ejs +3 -0
- package/tmpl/files/module.server/layers/logics.ejs +73 -0
- package/tmpl/files/module.server/layers/models.ejs +68 -0
- package/tmpl/files/module.server/layers/routes.ejs +50 -0
- package/tmpl/files/module.server/layers/routes.manifest.ejs +211 -0
- package/tmpl/files/module.server/layers/routes.ws.ejs +29 -0
- package/tmpl/files/module.server/validationEnv.ejs +5 -0
- package/tmpl/files/notComponent.ejs +57 -0
- package/tmpl/files/notService.ejs +39 -0
- package/scaffold/field.js +0 -0
- package/scaffold/form.js +0 -0
- package/scaffold/logic.js +0 -0
- package/scaffold/model.js +0 -0
- package/scaffold/module.js +0 -0
- package/scaffold/route.js +0 -0
package/bin/not-builder.js
CHANGED
|
@@ -666,7 +666,8 @@ async function build_Server(pathToRoot, roles, targetName, targetManifest) {
|
|
|
666
666
|
},
|
|
667
667
|
rollupFile
|
|
668
668
|
);
|
|
669
|
-
let result =
|
|
669
|
+
//let result =
|
|
670
|
+
child_process.execFileSync(
|
|
670
671
|
"node",
|
|
671
672
|
[opts.rollup, "-c", rollupFile],
|
|
672
673
|
{
|
|
@@ -685,13 +686,10 @@ async function build_Server(pathToRoot, roles, targetName, targetManifest) {
|
|
|
685
686
|
}
|
|
686
687
|
|
|
687
688
|
//loading manifest file
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
console.error(e);
|
|
693
|
-
process.exit(1);
|
|
694
|
-
}
|
|
689
|
+
|
|
690
|
+
console.log("config path", configName);
|
|
691
|
+
config = lib.getConfReader(configName);
|
|
692
|
+
|
|
695
693
|
//searchig for targets
|
|
696
694
|
if (config.get("targets") && Object.keys(config.get("targets")).length > 0) {
|
|
697
695
|
//cycling through targets
|
package/bin/not-cli.mjs
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const TEMPLATE_OPTIONS = "__options__";
|
|
3
|
+
|
|
4
|
+
const VAR_PREFIX = "__";
|
|
5
|
+
import ejs from "ejs";
|
|
6
|
+
|
|
7
|
+
import { isAbsolute, resolve, join } from "node:path";
|
|
8
|
+
|
|
9
|
+
import { copyFile, constants, mkdir, writeFile } from "node:fs/promises";
|
|
10
|
+
|
|
11
|
+
import { cwd } from "node:process";
|
|
12
|
+
const CWD = cwd();
|
|
13
|
+
|
|
14
|
+
import * as url from "url";
|
|
15
|
+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
16
|
+
|
|
17
|
+
import inquirer from "inquirer";
|
|
18
|
+
import { Command, Option } from "commander";
|
|
19
|
+
const program = new Command();
|
|
20
|
+
|
|
21
|
+
//reads vars from user input, provides defaults
|
|
22
|
+
import * as Readers from "../src/cli/readers/index.mjs";
|
|
23
|
+
|
|
24
|
+
import * as Renderers from "../src/cli/renderers/index.mjs";
|
|
25
|
+
//file system structure
|
|
26
|
+
//directories
|
|
27
|
+
//files and information how to render them from which template and with what args with readers names
|
|
28
|
+
import ApplicationStructure from "../tmpl/dirs/app.mjs";
|
|
29
|
+
import ApplicationServerStructure from "../tmpl/dirs/server.mjs";
|
|
30
|
+
import ApplicationFrontStructure from "../tmpl/dirs/front.mjs";
|
|
31
|
+
import ApplicationStaticStructure from "../tmpl/dirs/static.mjs";
|
|
32
|
+
|
|
33
|
+
import ApplicationModuleServerStructure from "../tmpl/dirs/module.server.mjs";
|
|
34
|
+
import ApplicationModuleServerControllersCommonStructure from "../tmpl/dirs/module.server.controllers.common.mjs";
|
|
35
|
+
|
|
36
|
+
import ApplicationModuleFrontStructure from "../tmpl/dirs/module.front.mjs";
|
|
37
|
+
|
|
38
|
+
import { firstLetterToLower } from "../src/common.js";
|
|
39
|
+
|
|
40
|
+
const ApplicationSubStructures = {
|
|
41
|
+
server: ApplicationServerStructure,
|
|
42
|
+
front: ApplicationFrontStructure,
|
|
43
|
+
static: ApplicationStaticStructure,
|
|
44
|
+
"module.server": ApplicationModuleServerStructure,
|
|
45
|
+
"module.server.controllers.common":
|
|
46
|
+
ApplicationModuleServerControllersCommonStructure,
|
|
47
|
+
"module.front": ApplicationModuleFrontStructure,
|
|
48
|
+
};
|
|
49
|
+
//path to various templates
|
|
50
|
+
const PATH_TMPL = resolve(__dirname, "../tmpl/files");
|
|
51
|
+
const DEFAULT_SERVER_MODULES_SUB_PATH = "./app/server/modules";
|
|
52
|
+
const DEFAULT_FRONT_MODULES_SUB_PATH = "./app/front/src";
|
|
53
|
+
|
|
54
|
+
async function readArgs(structure, config) {
|
|
55
|
+
let result = {};
|
|
56
|
+
if (Object.hasOwn(structure, "args")) {
|
|
57
|
+
for (let entry of structure.args) {
|
|
58
|
+
if (!Object.hasOwn(config, entry)) {
|
|
59
|
+
console.log(
|
|
60
|
+
`no ${entry} in config, reading data from user input`
|
|
61
|
+
);
|
|
62
|
+
config[entry] = await Readers[entry](inquirer, config);
|
|
63
|
+
}
|
|
64
|
+
result[entry] = config[entry];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//console.log(JSON.stringify(result, null, 4));
|
|
68
|
+
if (Object.hasOwn(structure, "options")) {
|
|
69
|
+
result[TEMPLATE_OPTIONS] = structure.options;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function renderFile(input, dest, data) {
|
|
75
|
+
console.log("render", dest);
|
|
76
|
+
const renderedFileContent = await ejs.renderFile(input, data, {
|
|
77
|
+
async: true,
|
|
78
|
+
});
|
|
79
|
+
await writeFile(dest, renderedFileContent);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function createFileContent(filePath, structure, config) {
|
|
83
|
+
if (typeof structure == "string") {
|
|
84
|
+
await copyTmplFile(resolve(PATH_TMPL, structure), filePath);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (Object.hasOwn(structure, "tmpl")) {
|
|
88
|
+
const tmplFilePath = resolve(PATH_TMPL, structure.tmpl);
|
|
89
|
+
const data = await readArgs(structure, config);
|
|
90
|
+
await renderFile(tmplFilePath, filePath, data);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function copyTmplFile(from, to) {
|
|
95
|
+
try {
|
|
96
|
+
// console.log("cp", from, to);
|
|
97
|
+
await copyFile(from, to, constants.COPYFILE_EXCL);
|
|
98
|
+
} catch {
|
|
99
|
+
//console.error("The file could not be copied", from, to);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function createDir(dirPath) {
|
|
104
|
+
try {
|
|
105
|
+
//console.log("mkdir", dirPath);
|
|
106
|
+
await mkdir(dirPath, { recursive: true });
|
|
107
|
+
} catch {
|
|
108
|
+
// console.error("Can't create directory", dirPath);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isFilename(name, descr) {
|
|
113
|
+
if (descr.type === "file") {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (name.startsWith(VAR_PREFIX) && name.endsWith(VAR_PREFIX)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return name.indexOf(".") > -1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function isVariable(name) {
|
|
123
|
+
return name.startsWith(VAR_PREFIX) && name.endsWith(VAR_PREFIX);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function getVariableName(name) {
|
|
127
|
+
return name.replace(new RegExp(VAR_PREFIX, "g"), "");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function dirRequiresAbsentModules(subStructure, config) {
|
|
131
|
+
return (
|
|
132
|
+
Object.hasOwn(subStructure, "ifModules") &&
|
|
133
|
+
Array.isArray(subStructure.ifModules) &&
|
|
134
|
+
!subStructure.ifModules.every((entry) => config.modules.includes(entry))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function createDirContent(dest, structure = {}, config = {}) {
|
|
139
|
+
if (typeof structure === "string") {
|
|
140
|
+
//console.log("need to create sub structure", structure);
|
|
141
|
+
await createDirContent(
|
|
142
|
+
dest,
|
|
143
|
+
ApplicationSubStructures[structure],
|
|
144
|
+
config
|
|
145
|
+
);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const dirs = {};
|
|
149
|
+
//creating files first
|
|
150
|
+
for (let entry in structure) {
|
|
151
|
+
const subStructure = structure[entry];
|
|
152
|
+
if (isVariable(entry)) {
|
|
153
|
+
entry = config[getVariableName(entry)];
|
|
154
|
+
}
|
|
155
|
+
if (isFilename(entry, subStructure)) {
|
|
156
|
+
// console.log(dest, entry);
|
|
157
|
+
const filePath = join(dest, entry);
|
|
158
|
+
await createFileContent(filePath, subStructure, config);
|
|
159
|
+
} else {
|
|
160
|
+
dirs[entry] = subStructure;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//then going deeper
|
|
164
|
+
for (let entry in dirs) {
|
|
165
|
+
const subStructure = dirs[entry];
|
|
166
|
+
const directoryPath = join(dest, entry);
|
|
167
|
+
if (dirRequiresAbsentModules(subStructure, config)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
await createDir(directoryPath);
|
|
171
|
+
if (Object.hasOwn(subStructure, "content")) {
|
|
172
|
+
await createDirContent(directoryPath, subStructure.content, config);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function entitiesInLayers(layersList = []) {
|
|
178
|
+
return (
|
|
179
|
+
layersList.includes("models") ||
|
|
180
|
+
layersList.includes("routes") ||
|
|
181
|
+
layersList.includes("logics")
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function createLayersDirs(modules_dir, layersList, ModuleName) {
|
|
186
|
+
if (layersList.length) {
|
|
187
|
+
await createDir(resolve(modules_dir, ModuleName, "./src"));
|
|
188
|
+
}
|
|
189
|
+
for (let layer of layersList) {
|
|
190
|
+
await createDir(resolve(modules_dir, ModuleName, "./src", layer));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function createServerModule(modules_dir, config) {
|
|
195
|
+
//read module name
|
|
196
|
+
const ModuleName = await Readers.ModuleName(inquirer);
|
|
197
|
+
const moduleName = firstLetterToLower(ModuleName);
|
|
198
|
+
const moduleDir = resolve(modules_dir, ModuleName);
|
|
199
|
+
const moduleConfig = { ...config, moduleName, ModuleName };
|
|
200
|
+
await createDir(moduleDir);
|
|
201
|
+
//console.log(JSON.stringify(moduleConfig, null, 4));
|
|
202
|
+
await createDirContent(
|
|
203
|
+
moduleDir,
|
|
204
|
+
ApplicationSubStructures["module.server"],
|
|
205
|
+
moduleConfig
|
|
206
|
+
);
|
|
207
|
+
const layersList = moduleConfig.moduleLayers;
|
|
208
|
+
await createLayersDirs(modules_dir, layersList, ModuleName);
|
|
209
|
+
//list of entities and its presence thru all selected layers
|
|
210
|
+
let entitiesList = [];
|
|
211
|
+
if (entitiesInLayers(layersList)) {
|
|
212
|
+
//should collect all first, to have full list of items for index files imports
|
|
213
|
+
while (await Readers.isUserNeedCreateEntity(inquirer)) {
|
|
214
|
+
const entityData = await Readers.entityData(
|
|
215
|
+
inquirer,
|
|
216
|
+
config,
|
|
217
|
+
layersList
|
|
218
|
+
);
|
|
219
|
+
entitiesList.push(entityData);
|
|
220
|
+
}
|
|
221
|
+
for (let entityData of entitiesList) {
|
|
222
|
+
await renderEntityFiles(
|
|
223
|
+
resolve(moduleDir, "./src"),
|
|
224
|
+
entityData,
|
|
225
|
+
moduleConfig
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (layersList.includes("controllers")) {
|
|
229
|
+
await renderServerContollersIndexes(
|
|
230
|
+
resolve(moduleDir, "./src"),
|
|
231
|
+
entitiesList,
|
|
232
|
+
moduleConfig
|
|
233
|
+
);
|
|
234
|
+
await renderServerControllersCommons(
|
|
235
|
+
resolve(moduleDir, "./src/controllers"),
|
|
236
|
+
entitiesList,
|
|
237
|
+
moduleConfig
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function renderEntityFiles(module_src_dir, data, config) {
|
|
244
|
+
for (let layerName of data.layers) {
|
|
245
|
+
if (Object.hasOwn(Renderers, layerName)) {
|
|
246
|
+
await Renderers[layerName](
|
|
247
|
+
resolve(module_src_dir, `./${layerName}`),
|
|
248
|
+
data,
|
|
249
|
+
config,
|
|
250
|
+
renderFile,
|
|
251
|
+
PATH_TMPL,
|
|
252
|
+
createDir
|
|
253
|
+
);
|
|
254
|
+
} else {
|
|
255
|
+
console.error("No renderer for layer: ", layerName);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function renderServerContollersIndexes(
|
|
261
|
+
module_src_dir,
|
|
262
|
+
entitiesData,
|
|
263
|
+
config
|
|
264
|
+
) {
|
|
265
|
+
const subDirList = [...config.roles];
|
|
266
|
+
for (let dirName of subDirList) {
|
|
267
|
+
await Renderers.controllersIndex(
|
|
268
|
+
resolve(module_src_dir, `./controllers/${dirName}`),
|
|
269
|
+
entitiesData,
|
|
270
|
+
config,
|
|
271
|
+
renderFile,
|
|
272
|
+
PATH_TMPL,
|
|
273
|
+
createDir
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function renderServerControllersCommons(
|
|
279
|
+
module_src_dir,
|
|
280
|
+
entitiesData,
|
|
281
|
+
config
|
|
282
|
+
) {
|
|
283
|
+
const dirPath = resolve(module_src_dir, `./common`);
|
|
284
|
+
await createDir(dirPath);
|
|
285
|
+
await createDirContent(
|
|
286
|
+
dirPath,
|
|
287
|
+
ApplicationModuleServerControllersCommonStructure,
|
|
288
|
+
{}
|
|
289
|
+
);
|
|
290
|
+
await Renderers.controllersCommons(
|
|
291
|
+
dirPath,
|
|
292
|
+
entitiesData,
|
|
293
|
+
config,
|
|
294
|
+
renderFile,
|
|
295
|
+
PATH_TMPL
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async function createBootstrapFrontModule(modules_dir, config) {
|
|
300
|
+
await createDir(modules_dir);
|
|
301
|
+
await createDirContent(
|
|
302
|
+
modules_dir,
|
|
303
|
+
ApplicationSubStructures["module.front"],
|
|
304
|
+
config
|
|
305
|
+
);
|
|
306
|
+
for (let role of config.roles) {
|
|
307
|
+
await createDir(resolve(modules_dir, role));
|
|
308
|
+
const targetFrontModuleDir = resolve(modules_dir, role, "main");
|
|
309
|
+
await createDir(targetFrontModuleDir);
|
|
310
|
+
if (role !== "guest") {
|
|
311
|
+
await Renderers.frontModuleGuestMain(
|
|
312
|
+
targetFrontModuleDir,
|
|
313
|
+
config,
|
|
314
|
+
renderFile,
|
|
315
|
+
PATH_TMPL
|
|
316
|
+
);
|
|
317
|
+
} else {
|
|
318
|
+
await Renderers.frontModuleRoleMain(
|
|
319
|
+
targetFrontModuleDir,
|
|
320
|
+
config,
|
|
321
|
+
renderFile,
|
|
322
|
+
PATH_TMPL
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
program
|
|
329
|
+
.command("create")
|
|
330
|
+
.addOption(
|
|
331
|
+
new Option("-d, --dir <dir>").default(CWD, "current working directory")
|
|
332
|
+
)
|
|
333
|
+
.description("create application in target directory")
|
|
334
|
+
.action(async (opts) => {
|
|
335
|
+
// console.log("create command called :" + opts.dir);
|
|
336
|
+
if (!isAbsolute(opts.dir)) {
|
|
337
|
+
opts.dir = resolve(CWD, opts.dir);
|
|
338
|
+
}
|
|
339
|
+
console.log("creating application in", opts.dir);
|
|
340
|
+
const AppConfig = {};
|
|
341
|
+
//
|
|
342
|
+
AppConfig.AppName = await Readers.AppName(inquirer, AppConfig);
|
|
343
|
+
AppConfig.appName = await Readers.appName(inquirer, AppConfig);
|
|
344
|
+
AppConfig.roles = await Readers.roles(inquirer, AppConfig);
|
|
345
|
+
AppConfig.rolesSecondary = await Readers.rolesSecondary(
|
|
346
|
+
inquirer,
|
|
347
|
+
AppConfig
|
|
348
|
+
);
|
|
349
|
+
AppConfig.modules = await Readers.modules(inquirer, AppConfig);
|
|
350
|
+
await createDir(opts.dir);
|
|
351
|
+
await createDirContent(opts.dir, ApplicationStructure, AppConfig);
|
|
352
|
+
const PATH_MODULES_SERVER = resolve(
|
|
353
|
+
opts.dir,
|
|
354
|
+
DEFAULT_SERVER_MODULES_SUB_PATH
|
|
355
|
+
);
|
|
356
|
+
const PATH_MODULES_FRONT = resolve(
|
|
357
|
+
opts.dir,
|
|
358
|
+
DEFAULT_FRONT_MODULES_SUB_PATH
|
|
359
|
+
);
|
|
360
|
+
while (await Readers.isUserNeedCreateServerModule(inquirer)) {
|
|
361
|
+
await createServerModule(PATH_MODULES_SERVER, AppConfig);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (await Readers.isUserNeedFrontModuleBootstrap(inquirer)) {
|
|
365
|
+
await createBootstrapFrontModule(PATH_MODULES_FRONT, AppConfig);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
program.parse();
|
package/index.js
CHANGED
|
@@ -48,3 +48,9 @@ module.exports.Application = null;
|
|
|
48
48
|
module.exports.Bootstrap = require("./src/bootstrap");
|
|
49
49
|
/** Application generic helpers */
|
|
50
50
|
module.exports.Generic = require("./src/generic/index.js");
|
|
51
|
+
|
|
52
|
+
/** Application stylers */
|
|
53
|
+
//for page's meta information
|
|
54
|
+
module.exports.notMetasStyler = require("./src/metas.js");
|
|
55
|
+
//for http headers files, web pages, XHR etc
|
|
56
|
+
module.exports.notHeadersStyler = require("./src/headers.js");
|
package/package.json
CHANGED
|
@@ -1,130 +1,135 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
2
|
+
"name": "not-node",
|
|
3
|
+
"version": "6.1.0",
|
|
4
|
+
"description": "node complimentary part for client side notFramework.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "./node_modules/.bin/mocha --require mocha-suppress-logs --reporter spec --timeout 12000",
|
|
8
|
+
"lint": "./node_modules/.bin/eslint ./src --fix",
|
|
9
|
+
"pretest": "./node_modules/.bin/eslint ./src",
|
|
10
|
+
"docs": "./node_modules/.bin/jsdoc -c jsdoc.json",
|
|
11
|
+
"js-watch": "watch 'npm run cover' ./src ./test --interval=5",
|
|
12
|
+
"watch:build:cover:dev": "npm-run-all --parallel js-watch",
|
|
13
|
+
"cover": "nyc npm test",
|
|
14
|
+
"clear:playground": "rm -rf ./playground"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"not-node": "./bin/not-node.js",
|
|
18
|
+
"not-cli": "./bin/not-cli.mjs",
|
|
19
|
+
"not-builder": "./bin/not-builder.js"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">14.9"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/interrupter/not-node.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"notFramework",
|
|
30
|
+
"node"
|
|
31
|
+
],
|
|
32
|
+
"author": "interrupter <levoe.milo@mail.ru> (http://github.com/interrupter)",
|
|
33
|
+
"license": "ISC",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/interrupter/not-node/issues"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"body-parser": "^1.20.1",
|
|
39
|
+
"commander": "^9.5.0",
|
|
40
|
+
"compression": "^1.7.4",
|
|
41
|
+
"connect-mongodb-session": "^3.1.1",
|
|
42
|
+
"connect-redis": "^6.1.3",
|
|
43
|
+
"cors": "^2.8.5",
|
|
44
|
+
"deep-diff": "*",
|
|
45
|
+
"deepmerge": "^4.2.2",
|
|
46
|
+
"ejs": "^3.1.8",
|
|
47
|
+
"escape-string-regexp": "*",
|
|
48
|
+
"express": "^4.18.2",
|
|
49
|
+
"express-fileupload": "^1.4.0",
|
|
50
|
+
"express-session": "^1.17.3",
|
|
51
|
+
"fs-extra": "*",
|
|
52
|
+
"generate-password": "^1.7.0",
|
|
53
|
+
"helmet": "^6.0.1",
|
|
54
|
+
"inquirer": "^9.1.4",
|
|
55
|
+
"jsonwebtoken": "^9.0.0",
|
|
56
|
+
"lower-case": "*",
|
|
57
|
+
"method-override": "^3.0.0",
|
|
58
|
+
"mock-require": "^3.0.3",
|
|
59
|
+
"mongoose": "*",
|
|
60
|
+
"mongoose-validator": "*",
|
|
61
|
+
"nconf": "*",
|
|
62
|
+
"not-config": "^0.1.5",
|
|
63
|
+
"not-error": "^0.2.5",
|
|
64
|
+
"not-filter": "*",
|
|
65
|
+
"not-inform": "^0.0.28",
|
|
66
|
+
"not-locale": "*",
|
|
67
|
+
"not-log": "^0.0.20",
|
|
68
|
+
"not-monitor": "^0.0.13",
|
|
69
|
+
"not-path": "^1.0.4",
|
|
70
|
+
"not-validation": "^0.0.8",
|
|
71
|
+
"rate-limiter-flexible": "^2.4.1",
|
|
72
|
+
"redis": "^4.5.1",
|
|
73
|
+
"redlock": "^5.0.0-beta.2",
|
|
74
|
+
"rfdc": "^1.3.0",
|
|
75
|
+
"rmdir": "^1.2.0",
|
|
76
|
+
"serve-static": "*",
|
|
77
|
+
"simple-git": "*",
|
|
78
|
+
"validator": "*",
|
|
79
|
+
"yargs": "*"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"babel-eslint": "^10.1.0",
|
|
83
|
+
"chai": "*",
|
|
84
|
+
"chai-as-promised": "*",
|
|
85
|
+
"eslint": "^8.31.0",
|
|
86
|
+
"eslint-plugin-node": "^11.1.0",
|
|
87
|
+
"eslint-plugin-sonarjs": "^0.17.0",
|
|
88
|
+
"ink-docstrap": "^1.3.2",
|
|
89
|
+
"ioredis": "^5.2.4",
|
|
90
|
+
"jsdoc": "^4.0.0",
|
|
91
|
+
"mocha": "*",
|
|
92
|
+
"mocha-suppress-logs": "^0.3.1",
|
|
93
|
+
"mongodb-memory-server": "^8.11.0",
|
|
94
|
+
"npm-run-all": "^4.1.5",
|
|
95
|
+
"nyc": "^15.1.0",
|
|
96
|
+
"retire": "^3.2.1"
|
|
97
|
+
},
|
|
98
|
+
"homepage": "https://github.com/interrupter/not-node#readme",
|
|
99
|
+
"nyc": {
|
|
100
|
+
"include": [
|
|
101
|
+
"index.js",
|
|
102
|
+
"src/**/**/**.js"
|
|
103
|
+
],
|
|
104
|
+
"exclude": [
|
|
105
|
+
"tests/**/**/**/**.js"
|
|
106
|
+
],
|
|
107
|
+
"reporter": [
|
|
108
|
+
"html"
|
|
109
|
+
],
|
|
110
|
+
"check-coverage": false,
|
|
111
|
+
"per-file": true,
|
|
112
|
+
"lines": 95,
|
|
113
|
+
"statements": 95,
|
|
114
|
+
"functions": 95,
|
|
115
|
+
"branches": 95,
|
|
116
|
+
"watermarks": {
|
|
117
|
+
"lines": [
|
|
118
|
+
80,
|
|
119
|
+
95
|
|
120
|
+
],
|
|
121
|
+
"functions": [
|
|
122
|
+
80,
|
|
123
|
+
95
|
|
124
|
+
],
|
|
125
|
+
"branches": [
|
|
126
|
+
80,
|
|
127
|
+
95
|
|
128
|
+
],
|
|
129
|
+
"statements": [
|
|
130
|
+
80,
|
|
131
|
+
95
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
130
135
|
}
|