not-node 6.0.7 → 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 +418 -293
- 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/identity/identity.js +0 -1
- 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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const DEFAULT = {
|
|
2
|
+
db: "test",
|
|
3
|
+
host: "localhost",
|
|
4
|
+
user: "",
|
|
5
|
+
pass: "",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function collectData(inquirer) {
|
|
9
|
+
return inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "hostname",
|
|
13
|
+
message: "MongoDB Hostname",
|
|
14
|
+
default: DEFAULT.host,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "db",
|
|
19
|
+
message: "MongoDB DB name",
|
|
20
|
+
default: DEFAULT.db,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "user",
|
|
25
|
+
message: "MongoDB User",
|
|
26
|
+
default: DEFAULT.user,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "password",
|
|
30
|
+
mask: "*",
|
|
31
|
+
name: "pass",
|
|
32
|
+
message: "MongoDB Pass",
|
|
33
|
+
default: DEFAULT.pass,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "input",
|
|
37
|
+
name: "authSource",
|
|
38
|
+
message: "MongoDB authSource",
|
|
39
|
+
default: "admin",
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default (inquirer) => {
|
|
45
|
+
return inquirer
|
|
46
|
+
.prompt([
|
|
47
|
+
{
|
|
48
|
+
type: "confirm",
|
|
49
|
+
name: "enabled",
|
|
50
|
+
message: "Configure mongoose?",
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
])
|
|
54
|
+
.then((answer) => {
|
|
55
|
+
if (answer.enabled) {
|
|
56
|
+
return collectData(inquirer);
|
|
57
|
+
} else {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import collectMongooseOptions from "./db/mongoose.mjs";
|
|
2
|
+
import collectRedisOptions from "./db/redis.mjs";
|
|
3
|
+
import collectIORedisOptions from "./db/ioredis.mjs";
|
|
4
|
+
|
|
5
|
+
async function collectData(inquirer) {
|
|
6
|
+
return {
|
|
7
|
+
mongoose: await collectMongooseOptions(inquirer),
|
|
8
|
+
redis: await collectRedisOptions(inquirer),
|
|
9
|
+
ioredis: await collectIORedisOptions(inquirer),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default (inquirer) => {
|
|
14
|
+
return inquirer
|
|
15
|
+
.prompt([
|
|
16
|
+
{
|
|
17
|
+
type: "confirm",
|
|
18
|
+
name: "enabled",
|
|
19
|
+
message: "Add DB connections options",
|
|
20
|
+
default: true,
|
|
21
|
+
},
|
|
22
|
+
])
|
|
23
|
+
.then(({ enabled }) => {
|
|
24
|
+
if (enabled) {
|
|
25
|
+
return collectData(inquirer);
|
|
26
|
+
} else {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { firstLetterToLower } from "../../common.js";
|
|
2
|
+
import actions from "./actions.mjs";
|
|
3
|
+
import fields from "./fields.mjs";
|
|
4
|
+
import entityLayers from "./entityLayers.mjs";
|
|
5
|
+
import modelValidators from "./modelValidators.mjs";
|
|
6
|
+
import modelVersioning from "./modelVersioning.mjs";
|
|
7
|
+
import modelIncrement from "./modelIncrement.mjs";
|
|
8
|
+
|
|
9
|
+
const DEFAULT = {
|
|
10
|
+
ModelName: "NewModel",
|
|
11
|
+
modelName: "newModel",
|
|
12
|
+
actions: [],
|
|
13
|
+
fields: [],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function collectData(inquirer) {
|
|
17
|
+
return inquirer.prompt([
|
|
18
|
+
{
|
|
19
|
+
type: "input",
|
|
20
|
+
name: "ModelName",
|
|
21
|
+
message: "Entity name",
|
|
22
|
+
default: DEFAULT.ModelName,
|
|
23
|
+
},
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default (inquirer, config, layersList) => {
|
|
28
|
+
return collectData(inquirer).then(async (answer) => {
|
|
29
|
+
const result = {
|
|
30
|
+
...answer,
|
|
31
|
+
modelName: firstLetterToLower(answer.ModelName),
|
|
32
|
+
actions: await actions(inquirer),
|
|
33
|
+
fields: await fields(inquirer),
|
|
34
|
+
layers: await entityLayers(inquirer, config, layersList),
|
|
35
|
+
};
|
|
36
|
+
if (result.layers.includes("models")) {
|
|
37
|
+
result.validators = await modelValidators(inquirer);
|
|
38
|
+
result.versioning = await modelVersioning(inquirer);
|
|
39
|
+
result.increment = await modelIncrement(inquirer, result);
|
|
40
|
+
}
|
|
41
|
+
console.log("Entity data", JSON.stringify(result));
|
|
42
|
+
return result;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEFAULT_ENTITY_LAYERS } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
export default (inquirer, config, layersList = []) => {
|
|
4
|
+
return inquirer
|
|
5
|
+
.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: "checkbox",
|
|
8
|
+
message: "Select entity layers",
|
|
9
|
+
name: "layers",
|
|
10
|
+
choices: layersList
|
|
11
|
+
.filter((entry) => DEFAULT_ENTITY_LAYERS.includes(entry))
|
|
12
|
+
.map((name) => {
|
|
13
|
+
return {
|
|
14
|
+
name,
|
|
15
|
+
checked: true,
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
])
|
|
20
|
+
.then((answer) => answer.layers);
|
|
21
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function collectData(inquirer) {
|
|
2
|
+
return inquirer
|
|
3
|
+
.prompt([
|
|
4
|
+
{
|
|
5
|
+
type: "input",
|
|
6
|
+
name: "size",
|
|
7
|
+
message: "Filter page size",
|
|
8
|
+
default: 15,
|
|
9
|
+
},
|
|
10
|
+
])
|
|
11
|
+
.then((answer) => {
|
|
12
|
+
answer.pager = { size: answer.size };
|
|
13
|
+
return answer;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default (inquirer) => {
|
|
18
|
+
return inquirer
|
|
19
|
+
.prompt([
|
|
20
|
+
{
|
|
21
|
+
type: "confirm",
|
|
22
|
+
name: "enabled",
|
|
23
|
+
message: "Configure Filter module?",
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
])
|
|
27
|
+
.then((answer) => {
|
|
28
|
+
if (answer.enabled) {
|
|
29
|
+
return collectData(inquirer);
|
|
30
|
+
} else {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const DEFAULT_HOST = "https://localhost";
|
|
2
|
+
export default (inquirer) => {
|
|
3
|
+
return inquirer.prompt([
|
|
4
|
+
{
|
|
5
|
+
type: "input",
|
|
6
|
+
name: "development",
|
|
7
|
+
message: "Hostname (dev)",
|
|
8
|
+
default: DEFAULT_HOST,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "stage",
|
|
13
|
+
message: "Hostname (stage)",
|
|
14
|
+
default: DEFAULT_HOST,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "production",
|
|
19
|
+
message: "Hostname (production)",
|
|
20
|
+
default: DEFAULT_HOST,
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import actions from "./actions.mjs";
|
|
2
|
+
export { actions };
|
|
3
|
+
|
|
4
|
+
import AppDescription from "./AppDescription.mjs";
|
|
5
|
+
export { AppDescription };
|
|
6
|
+
|
|
7
|
+
import appName from "./appName.mjs";
|
|
8
|
+
export { appName };
|
|
9
|
+
|
|
10
|
+
import AppName from "./AppName.mjs";
|
|
11
|
+
export { AppName };
|
|
12
|
+
|
|
13
|
+
import cors from "./cors.mjs";
|
|
14
|
+
export { cors };
|
|
15
|
+
|
|
16
|
+
import db from "./db.mjs";
|
|
17
|
+
export { db };
|
|
18
|
+
|
|
19
|
+
import filter from "./filter.mjs";
|
|
20
|
+
export { filter };
|
|
21
|
+
|
|
22
|
+
import hostname from "./hostname.mjs";
|
|
23
|
+
export { hostname };
|
|
24
|
+
|
|
25
|
+
import fields from "./fields.mjs";
|
|
26
|
+
export { fields };
|
|
27
|
+
|
|
28
|
+
import init_root_user from "./init_root_user.mjs";
|
|
29
|
+
export { init_root_user };
|
|
30
|
+
|
|
31
|
+
import isUserNeedCreateEntity from "./isUserNeedCreateEntity.mjs";
|
|
32
|
+
export { isUserNeedCreateEntity };
|
|
33
|
+
|
|
34
|
+
import isUserNeedFrontModuleBootstrap from "./isUserNeedFrontModuleBootstrap.mjs";
|
|
35
|
+
export { isUserNeedFrontModuleBootstrap };
|
|
36
|
+
|
|
37
|
+
import isUserNeedCreateServerModule from "./isUserNeedCreateServerModule.mjs";
|
|
38
|
+
export { isUserNeedCreateServerModule };
|
|
39
|
+
|
|
40
|
+
import ModuleName from "./ModuleName.mjs";
|
|
41
|
+
export { ModuleName };
|
|
42
|
+
|
|
43
|
+
import ModelName from "./ModelName.mjs";
|
|
44
|
+
export { ModelName };
|
|
45
|
+
|
|
46
|
+
import modules from "./modules.mjs";
|
|
47
|
+
export { modules };
|
|
48
|
+
|
|
49
|
+
import not_node_monitor from "./not_node_monitor.mjs";
|
|
50
|
+
export { not_node_monitor };
|
|
51
|
+
|
|
52
|
+
import not_node_reporter from "./not_node_reporter.mjs";
|
|
53
|
+
export { not_node_reporter };
|
|
54
|
+
|
|
55
|
+
import port from "./port.mjs";
|
|
56
|
+
export { port };
|
|
57
|
+
|
|
58
|
+
import roles from "./roles.mjs";
|
|
59
|
+
export { roles };
|
|
60
|
+
|
|
61
|
+
import rolesSecondary from "./rolesSecondary.mjs";
|
|
62
|
+
export { rolesSecondary };
|
|
63
|
+
|
|
64
|
+
import secret from "./secret.mjs";
|
|
65
|
+
export { secret };
|
|
66
|
+
|
|
67
|
+
import entityData from "./entityData.mjs";
|
|
68
|
+
export { entityData };
|
|
69
|
+
|
|
70
|
+
import entityLayers from "./entityLayers.mjs";
|
|
71
|
+
export { entityLayers };
|
|
72
|
+
|
|
73
|
+
import moduleLayers from "./moduleLayers.mjs";
|
|
74
|
+
export { moduleLayers };
|
|
75
|
+
|
|
76
|
+
import session from "./session.mjs";
|
|
77
|
+
export { session };
|
|
78
|
+
|
|
79
|
+
import ssl from "./ssl.mjs";
|
|
80
|
+
export { ssl };
|
|
81
|
+
|
|
82
|
+
import user from "./user.mjs";
|
|
83
|
+
export { user };
|
|
84
|
+
|
|
85
|
+
import ws from "./ws.mjs";
|
|
86
|
+
export { ws };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import generator from "generate-password";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_PASSWORD = generator.generate({
|
|
4
|
+
length: 10,
|
|
5
|
+
numbers: true,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
function collectInitRootUser(inquirer) {
|
|
9
|
+
return inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "name",
|
|
13
|
+
message: "Name",
|
|
14
|
+
default: "root",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "email",
|
|
19
|
+
message: "Email",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: "input",
|
|
23
|
+
name: "password",
|
|
24
|
+
message: "Password",
|
|
25
|
+
default: DEFAULT_PASSWORD,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "input",
|
|
29
|
+
name: "passwordConfirmation",
|
|
30
|
+
message: "Re-type password",
|
|
31
|
+
validate(inpt, answer) {
|
|
32
|
+
return inpt === answer.password;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default (inquirer) => {
|
|
39
|
+
inquirer
|
|
40
|
+
.prompt([
|
|
41
|
+
{
|
|
42
|
+
type: "confirm",
|
|
43
|
+
name: "enabled",
|
|
44
|
+
message: "Init system superuser",
|
|
45
|
+
default: true,
|
|
46
|
+
},
|
|
47
|
+
])
|
|
48
|
+
.then(({ enabled }) => {
|
|
49
|
+
if (enabled) {
|
|
50
|
+
return collectInitRootUser(inquirer);
|
|
51
|
+
} else {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import modelIncrementFilter from "./modelIncrementFilter.mjs";
|
|
2
|
+
|
|
3
|
+
async function collectData(inquirer, config) {
|
|
4
|
+
const filter = await modelIncrementFilter(inquirer, config);
|
|
5
|
+
if (filter) {
|
|
6
|
+
return {
|
|
7
|
+
options: {
|
|
8
|
+
filter,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default (inquirer, config) => {
|
|
16
|
+
return inquirer
|
|
17
|
+
.prompt([
|
|
18
|
+
{
|
|
19
|
+
type: "confirm",
|
|
20
|
+
name: "enabled",
|
|
21
|
+
message: "Model should have auto-increment field?",
|
|
22
|
+
default: false,
|
|
23
|
+
},
|
|
24
|
+
])
|
|
25
|
+
.then((answer) => {
|
|
26
|
+
if (answer.enabled) {
|
|
27
|
+
return collectData(inquirer, config);
|
|
28
|
+
} else {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function collectData(inquirer, fields) {
|
|
2
|
+
let defaultFields = [];
|
|
3
|
+
["ownerModel", "owner"].forEach((entry) => {
|
|
4
|
+
if (fields.includes(entry)) defaultFields.push(entry);
|
|
5
|
+
});
|
|
6
|
+
return inquirer
|
|
7
|
+
.prompt([
|
|
8
|
+
{
|
|
9
|
+
type: "checkbox",
|
|
10
|
+
name: "filter",
|
|
11
|
+
message: "Group auto-increment indexes by",
|
|
12
|
+
choices: fields.map((name) => {
|
|
13
|
+
return {
|
|
14
|
+
name,
|
|
15
|
+
checked: defaultFields.includes(name),
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
default: defaultFields,
|
|
19
|
+
validate(answer) {
|
|
20
|
+
if (answer.length < 1) {
|
|
21
|
+
return "You must choose at least one field.";
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
])
|
|
27
|
+
.then((answer) => {
|
|
28
|
+
return answer.filter;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default (inquirer, modelConfig) => {
|
|
33
|
+
return inquirer
|
|
34
|
+
.prompt([
|
|
35
|
+
{
|
|
36
|
+
type: "confirm",
|
|
37
|
+
name: "enabled",
|
|
38
|
+
message: "Model auto-increment field global?",
|
|
39
|
+
default: true,
|
|
40
|
+
},
|
|
41
|
+
])
|
|
42
|
+
.then((answer) => {
|
|
43
|
+
if (answer.enabled) {
|
|
44
|
+
return false;
|
|
45
|
+
} else {
|
|
46
|
+
return collectData(inquirer, modelConfig.fields);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const DEFAULT = {
|
|
2
|
+
db: "test",
|
|
3
|
+
host: "localhost",
|
|
4
|
+
user: "",
|
|
5
|
+
pass: "",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function collectData(inquirer) {
|
|
9
|
+
return inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "hostname",
|
|
13
|
+
message: "MongoDB Hostname",
|
|
14
|
+
default: DEFAULT.host,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "db",
|
|
19
|
+
message: "MongoDB DB name",
|
|
20
|
+
default: DEFAULT.db,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "user",
|
|
25
|
+
message: "MongoDB User",
|
|
26
|
+
default: DEFAULT.user,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "password",
|
|
30
|
+
mask: "*",
|
|
31
|
+
name: "pass",
|
|
32
|
+
message: "MongoDB Pass",
|
|
33
|
+
default: DEFAULT.pass,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "input",
|
|
37
|
+
name: "authSource",
|
|
38
|
+
message: "MongoDB authSource",
|
|
39
|
+
default: "admin",
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default (inquirer) => {
|
|
45
|
+
return inquirer
|
|
46
|
+
.prompt([
|
|
47
|
+
{
|
|
48
|
+
type: "confirm",
|
|
49
|
+
name: "enabled",
|
|
50
|
+
message: "Configure model?",
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
])
|
|
54
|
+
.then((answer) => {
|
|
55
|
+
if (answer.enabled) {
|
|
56
|
+
return collectData(inquirer);
|
|
57
|
+
} else {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DEFAULT_MODULE_LAYERS } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
export default (inquirer) => {
|
|
4
|
+
return inquirer
|
|
5
|
+
.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: "checkbox",
|
|
8
|
+
message: "Select module layers",
|
|
9
|
+
name: "layers",
|
|
10
|
+
choices: DEFAULT_MODULE_LAYERS.map((name) => {
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
checked: true,
|
|
14
|
+
};
|
|
15
|
+
}),
|
|
16
|
+
validate(answer) {
|
|
17
|
+
if (answer.length < 1) {
|
|
18
|
+
return "You must choose at least one layer.";
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
])
|
|
24
|
+
.then((answer) => answer.layers);
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DEFAULT_MODULES_SET, DEFAULT_MODULES_SET_ENABLED } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
export default (inquirer) => {
|
|
4
|
+
return inquirer
|
|
5
|
+
.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: "checkbox",
|
|
8
|
+
message: "Select additional modules set",
|
|
9
|
+
name: "modules",
|
|
10
|
+
choices: DEFAULT_MODULES_SET.map((entry) => {
|
|
11
|
+
return {
|
|
12
|
+
name: entry,
|
|
13
|
+
checked: DEFAULT_MODULES_SET_ENABLED.includes(entry),
|
|
14
|
+
};
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
])
|
|
18
|
+
.then((answer) => answer.modules);
|
|
19
|
+
};
|