@x-fiber-sys/dev-tool 0.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/README.md +11 -0
- package/dist/_cjs/common/action-kind.js +17 -0
- package/dist/_cjs/common/constants.js +8 -0
- package/dist/_cjs/common/document-kind.js +32 -0
- package/dist/_cjs/common/envs-kind.js +142 -0
- package/dist/_cjs/common/index.js +25 -0
- package/dist/_cjs/common/libraries-kind.js +116 -0
- package/dist/_cjs/common/menu-items.js +8 -0
- package/dist/_cjs/common/protocol-kind.js +62 -0
- package/dist/_cjs/common/symbols-kind.js +45 -0
- package/dist/_cjs/common/typings-kind.js +9 -0
- package/dist/_cjs/debug.js +195 -0
- package/dist/_cjs/index.js +5 -0
- package/dist/_cjs/initiator.js +28 -0
- package/dist/_cjs/schemas/generate.schema.js +2 -0
- package/dist/_cjs/schemas/index.js +18 -0
- package/dist/_cjs/schemas/row.schema.js +2 -0
- package/dist/_cjs/services/generator.js +107 -0
- package/dist/_cjs/services/index.js +19 -0
- package/dist/_cjs/services/installer.js +46 -0
- package/dist/_cjs/services/navigator.js +69 -0
- package/dist/_cjs/services/runner.js +20 -0
- package/dist/_cjs/templates/cache.template.js +58 -0
- package/dist/_cjs/templates/envs.template.js +115 -0
- package/dist/_cjs/templates/index.js +26 -0
- package/dist/_cjs/templates/index.template.js +38 -0
- package/dist/_cjs/templates/initiator.template.js +750 -0
- package/dist/_cjs/templates/ioc.template.js +107 -0
- package/dist/_cjs/templates/module.template.js +132 -0
- package/dist/_cjs/templates/pg-repository.template.js +432 -0
- package/dist/_cjs/templates/sys.template.js +110 -0
- package/dist/_cjs/templates/transport.template.js +490 -0
- package/dist/_cjs/templates/validator.template.js +16 -0
- package/dist/_cjs/types/index.js +2 -0
- package/dist/_cjs/types/module.js +2 -0
- package/dist/_cjs/types/service.js +2 -0
- package/dist/_cjs/utils/hello.js +17 -0
- package/dist/_cjs/utils/index.js +18 -0
- package/dist/_cjs/utils/ts-utils.js +7 -0
- package/dist/_types/common/action-kind.d.ts +15 -0
- package/dist/_types/common/constants.d.ts +5 -0
- package/dist/_types/common/document-kind.d.ts +29 -0
- package/dist/_types/common/envs-kind.d.ts +390 -0
- package/dist/_types/common/index.d.ts +9 -0
- package/dist/_types/common/libraries-kind.d.ts +115 -0
- package/dist/_types/common/menu-items.d.ts +7 -0
- package/dist/_types/common/protocol-kind.d.ts +59 -0
- package/dist/_types/common/symbols-kind.d.ts +44 -0
- package/dist/_types/common/typings-kind.d.ts +6 -0
- package/dist/_types/debug.d.ts +19 -0
- package/dist/_types/index.d.ts +2 -0
- package/dist/_types/initiator.d.ts +7 -0
- package/dist/_types/schemas/generate.schema.d.ts +38 -0
- package/dist/_types/schemas/index.d.ts +2 -0
- package/dist/_types/schemas/row.schema.d.ts +20 -0
- package/dist/_types/services/generator.d.ts +15 -0
- package/dist/_types/services/index.d.ts +3 -0
- package/dist/_types/services/installer.d.ts +5 -0
- package/dist/_types/services/navigator.d.ts +10 -0
- package/dist/_types/services/runner.d.ts +3 -0
- package/dist/_types/templates/cache.template.d.ts +8 -0
- package/dist/_types/templates/envs.template.d.ts +5 -0
- package/dist/_types/templates/index.d.ts +10 -0
- package/dist/_types/templates/index.template.d.ts +7 -0
- package/dist/_types/templates/initiator.template.d.ts +33 -0
- package/dist/_types/templates/ioc.template.d.ts +9 -0
- package/dist/_types/templates/module.template.d.ts +8 -0
- package/dist/_types/templates/pg-repository.template.d.ts +19 -0
- package/dist/_types/templates/sys.template.d.ts +23 -0
- package/dist/_types/templates/transport.template.d.ts +15 -0
- package/dist/_types/templates/validator.template.d.ts +7 -0
- package/dist/_types/types/index.d.ts +2 -0
- package/dist/_types/types/module.d.ts +10 -0
- package/dist/_types/types/service.d.ts +21 -0
- package/dist/_types/utils/hello.d.ts +1 -0
- package/dist/_types/utils/index.d.ts +2 -0
- package/dist/_types/utils/ts-utils.d.ts +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Initiator = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const services_1 = require("./services");
|
|
7
|
+
class Initiator {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._generator = new services_1.Generator();
|
|
10
|
+
this._navigator = new services_1.Navigator();
|
|
11
|
+
}
|
|
12
|
+
async start() {
|
|
13
|
+
(0, utils_1.hello)();
|
|
14
|
+
await this._menu();
|
|
15
|
+
}
|
|
16
|
+
async _menu() {
|
|
17
|
+
const mapping = {
|
|
18
|
+
[common_1.MenuItemsMapping.generate_service]: async () => await this._generator.createService(),
|
|
19
|
+
[common_1.MenuItemsMapping.help]: () => this._generator.help(),
|
|
20
|
+
[common_1.MenuItemsMapping.exit]: () => this._generator.exit(),
|
|
21
|
+
};
|
|
22
|
+
const item = await this._navigator.main();
|
|
23
|
+
await mapping[item]();
|
|
24
|
+
if (item !== common_1.MenuItemsMapping.exit)
|
|
25
|
+
await this._menu();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Initiator = Initiator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./row.schema"), exports);
|
|
18
|
+
__exportStar(require("./generate.schema"), exports);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Generator = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const prettier_1 = require("prettier");
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const navigator_1 = require("./navigator");
|
|
8
|
+
const templates_1 = require("../templates");
|
|
9
|
+
const runner_1 = require("./runner");
|
|
10
|
+
class Generator {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._navigator = new navigator_1.Navigator();
|
|
13
|
+
this._runner = new runner_1.Runner();
|
|
14
|
+
this._kind = 'business';
|
|
15
|
+
this._formatConfig = {
|
|
16
|
+
trailingComma: 'all',
|
|
17
|
+
tabWidth: 2,
|
|
18
|
+
useTabs: false,
|
|
19
|
+
singleQuote: true,
|
|
20
|
+
printWidth: 100,
|
|
21
|
+
semi: false,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
get _cwd() {
|
|
25
|
+
return process.cwd() + `/test/${this._kind}`;
|
|
26
|
+
}
|
|
27
|
+
get _schema() {
|
|
28
|
+
return (0, node_path_1.join)(this._cwd, '/src/schemas/latest');
|
|
29
|
+
}
|
|
30
|
+
get _types() {
|
|
31
|
+
return (0, node_path_1.join)(this._cwd, '/src/types');
|
|
32
|
+
}
|
|
33
|
+
async createService() {
|
|
34
|
+
const { kind, name, description } = await this._navigator.service();
|
|
35
|
+
this._kind = kind;
|
|
36
|
+
const packages = await this._navigator.packages();
|
|
37
|
+
const concept = {
|
|
38
|
+
service: name,
|
|
39
|
+
libraries: {
|
|
40
|
+
axios: packages.includes('Axios'),
|
|
41
|
+
scrambler: packages.includes('Scrambler'),
|
|
42
|
+
emails: packages.includes('Emails'),
|
|
43
|
+
slack: packages.includes('Slack'),
|
|
44
|
+
telegram: packages.includes('Telegram'),
|
|
45
|
+
redis: packages.includes('Redis'),
|
|
46
|
+
broker: packages.includes('Kafka broker'),
|
|
47
|
+
clickHouse: packages.includes('Click House'),
|
|
48
|
+
postgres: packages.includes('Postgres'),
|
|
49
|
+
timescale: packages.includes('Timescale'),
|
|
50
|
+
storix: packages.includes('Storix'),
|
|
51
|
+
manager: packages.includes('Manager'),
|
|
52
|
+
queue: packages.includes('Bull queue'),
|
|
53
|
+
httpServer: packages.includes('Http server'),
|
|
54
|
+
wsServer: packages.includes('Ws server'),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
// contents
|
|
58
|
+
new templates_1.InitiatorTemplate((0, node_path_1.join)(this._cwd, '/src/initiator.ts'), concept).generate();
|
|
59
|
+
new templates_1.IocTemplate((0, node_path_1.join)(this._cwd, '/src/ioc.ts'), concept).generate();
|
|
60
|
+
new templates_1.IndexTemplate((0, node_path_1.join)(this._cwd, '/src/index.ts')).generate();
|
|
61
|
+
// file structures
|
|
62
|
+
const sys = new templates_1.SysTemplate();
|
|
63
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._schema, '/index.ts'), '');
|
|
64
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._schema, '/errors/error-codes.ts'), '');
|
|
65
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._schema, '/errors/errors.ts'), '');
|
|
66
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._schema, '/errors/index.ts'), '');
|
|
67
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._schema, '/domains/index.ts'), '');
|
|
68
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._schema, '/common/index.ts'), '');
|
|
69
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._types, 'broker.d.ts'), '');
|
|
70
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._types, 'envs.d.ts'), '');
|
|
71
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._types, 'service.d.ts'), '');
|
|
72
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._types, 'sql.d.ts'), '');
|
|
73
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._cwd, '.env'), '');
|
|
74
|
+
sys.eslintrc((0, node_path_1.join)(this._cwd, '.eslintrc.cjs'));
|
|
75
|
+
sys.dockerfileDev({ path: (0, node_path_1.join)(this._cwd, 'Dockerfile.dev'), name, kind });
|
|
76
|
+
(0, fs_extra_1.outputFileSync)((0, node_path_1.join)(this._cwd, 'Dockerfile.dev'), '');
|
|
77
|
+
(0, fs_extra_1.outputJSONSync)((0, node_path_1.join)(this._cwd, 'nodemon.json'), sys.nodemon());
|
|
78
|
+
(0, fs_extra_1.outputJSONSync)((0, node_path_1.join)(this._cwd, 'package.json'), sys.package({ name, description }));
|
|
79
|
+
(0, fs_extra_1.outputJSONSync)((0, node_path_1.join)(this._cwd, 'project.json'), sys.project(name));
|
|
80
|
+
(0, fs_extra_1.outputJSONSync)((0, node_path_1.join)(this._cwd, 'tsconfig.json'), sys.tsconfig(name));
|
|
81
|
+
await this._format();
|
|
82
|
+
}
|
|
83
|
+
async _format() {
|
|
84
|
+
const exclude = ['.env', 'Dockerfile.dev', 'README.md'];
|
|
85
|
+
await this._walk(this._cwd, async (path) => {
|
|
86
|
+
if (exclude.find((e) => path.includes(e)))
|
|
87
|
+
return;
|
|
88
|
+
const content = (0, fs_extra_1.readFileSync)(path, { encoding: 'utf-8' });
|
|
89
|
+
await (0, prettier_1.format)(content, { ...this._formatConfig, filepath: path });
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async _walk(directory, callback) {
|
|
93
|
+
const entries = await (0, fs_extra_1.readdir)(directory, { withFileTypes: true });
|
|
94
|
+
for (const entry of entries) {
|
|
95
|
+
const path = (0, node_path_1.join)(directory, entry.name);
|
|
96
|
+
if (entry.isDirectory()) {
|
|
97
|
+
await this._walk(path, callback);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (entry.isFile())
|
|
101
|
+
await callback(path);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
help() { }
|
|
105
|
+
exit() { }
|
|
106
|
+
}
|
|
107
|
+
exports.Generator = Generator;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generator"), exports);
|
|
18
|
+
__exportStar(require("./runner"), exports);
|
|
19
|
+
__exportStar(require("./navigator"), exports);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Installer = void 0;
|
|
4
|
+
class Installer {
|
|
5
|
+
packages({ libraries }) {
|
|
6
|
+
const packages = [
|
|
7
|
+
'@x-fiber-sys/be-common',
|
|
8
|
+
'@x-fiber-sys/be-config',
|
|
9
|
+
'@x-fiber-sys/context',
|
|
10
|
+
'@x-fiber-sys/contract',
|
|
11
|
+
'@x-fiber-sys/reflection',
|
|
12
|
+
'@x-fiber-sys/logger',
|
|
13
|
+
'@x-fiber-sys/tracer',
|
|
14
|
+
];
|
|
15
|
+
if (libraries.axios)
|
|
16
|
+
packages.push('@x-fiber-sys/be-axios');
|
|
17
|
+
if (libraries.scrambler)
|
|
18
|
+
packages.push('@x-fiber-sys/scrambler');
|
|
19
|
+
if (libraries.emails)
|
|
20
|
+
packages.push('@x-fiber-sys/emails');
|
|
21
|
+
if (libraries.slack)
|
|
22
|
+
packages.push('@x-fiber-sys/slack');
|
|
23
|
+
if (libraries.telegram)
|
|
24
|
+
packages.push('@x-fiber-sys/telegram');
|
|
25
|
+
if (libraries.redis)
|
|
26
|
+
packages.push('@x-fiber-sys/redis');
|
|
27
|
+
if (libraries.broker)
|
|
28
|
+
packages.push('@x-fiber-sys/kafka');
|
|
29
|
+
if (libraries.clickHouse)
|
|
30
|
+
packages.push('@x-fiber-sys/click-house');
|
|
31
|
+
if (libraries.postgres || libraries.timescale)
|
|
32
|
+
packages.push('@x-fiber-sys/sql');
|
|
33
|
+
if (libraries.storix)
|
|
34
|
+
packages.push('@x-fiber-sys/storix');
|
|
35
|
+
if (libraries.manager)
|
|
36
|
+
packages.push('@x-fiber-sys/manager');
|
|
37
|
+
if (libraries.queue)
|
|
38
|
+
packages.push('@x-fiber-sys/queue');
|
|
39
|
+
if (libraries.httpServer)
|
|
40
|
+
packages.push('@x-fiber-sys/http-server');
|
|
41
|
+
if (libraries.wsServer)
|
|
42
|
+
packages.push('@x-fiber-sys/ws-server');
|
|
43
|
+
return packages;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Installer = Installer;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Navigator = void 0;
|
|
4
|
+
const enquirer_1 = require("enquirer");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
class Navigator {
|
|
7
|
+
async main() {
|
|
8
|
+
const { item } = await (0, enquirer_1.prompt)([
|
|
9
|
+
{
|
|
10
|
+
type: 'select',
|
|
11
|
+
name: 'item',
|
|
12
|
+
message: 'Select the desired menu item',
|
|
13
|
+
choices: [
|
|
14
|
+
{
|
|
15
|
+
name: common_1.MenuItemsMapping.generate_service,
|
|
16
|
+
message: '🛠️ Generate a new service module for your project',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: common_1.MenuItemsMapping.help,
|
|
20
|
+
message: '❓ Show help information about available commands',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: common_1.MenuItemsMapping.exit,
|
|
24
|
+
message: '❌ Stopped commands process end close command line interface',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
return item;
|
|
30
|
+
}
|
|
31
|
+
async packages() {
|
|
32
|
+
const { item } = await (0, enquirer_1.prompt)([
|
|
33
|
+
{
|
|
34
|
+
type: 'multiselect',
|
|
35
|
+
name: 'item',
|
|
36
|
+
message: 'Select the desired menu item',
|
|
37
|
+
choices: Object.values(common_1.LibrariesNameMapping),
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
return item;
|
|
41
|
+
}
|
|
42
|
+
async service() {
|
|
43
|
+
// const { name } = await prompt<{ name: string }>([
|
|
44
|
+
// {
|
|
45
|
+
// type: 'input',
|
|
46
|
+
// name: 'name',
|
|
47
|
+
// message: '',
|
|
48
|
+
// },
|
|
49
|
+
// ])
|
|
50
|
+
//
|
|
51
|
+
// const { description } = await prompt<{ description: string }>([
|
|
52
|
+
// {
|
|
53
|
+
// type: 'input',
|
|
54
|
+
// name: 'description',
|
|
55
|
+
// message: '',
|
|
56
|
+
// },
|
|
57
|
+
// ])
|
|
58
|
+
//
|
|
59
|
+
// const { kind } = await prompt<{ kind: string }>([
|
|
60
|
+
// {
|
|
61
|
+
// type: 'input',
|
|
62
|
+
// name: 'kind',
|
|
63
|
+
// message: '',
|
|
64
|
+
// },
|
|
65
|
+
// ])
|
|
66
|
+
return { name: 'test', description: 'test-description', kind: 'business' };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Navigator = Navigator;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Runner = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
class Runner {
|
|
6
|
+
install(packages, dev = false) {
|
|
7
|
+
const args = ['install', ...packages];
|
|
8
|
+
if (dev)
|
|
9
|
+
args.push('--save-dev');
|
|
10
|
+
const result = (0, child_process_1.spawnSync)('npm', args, {
|
|
11
|
+
cwd: process.cwd() + '/test',
|
|
12
|
+
shell: true,
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
});
|
|
15
|
+
if (result.status !== 0) {
|
|
16
|
+
throw new Error(`npm init failed with code ${result.status}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Runner = Runner;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheTemplate = void 0;
|
|
4
|
+
const morphix_1 = require("@terra-versity/morphix");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
class CacheTemplate {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._imports = new morphix_1.ImportsSculptor();
|
|
10
|
+
this._class = new morphix_1.ClassSculptor();
|
|
11
|
+
this._variables = new morphix_1.VariablesSculptor();
|
|
12
|
+
}
|
|
13
|
+
content(concept) {
|
|
14
|
+
let source = new ts_morph_1.Project().createSourceFile('./index.ts', '', { overwrite: true });
|
|
15
|
+
const imports = [
|
|
16
|
+
{
|
|
17
|
+
module: common_1.LibrariesKindMapping.reflection,
|
|
18
|
+
namedImports: [
|
|
19
|
+
common_1.ReflectionKindMapping.bind,
|
|
20
|
+
common_1.ReflectionKindMapping.transport,
|
|
21
|
+
common_1.ReflectionKindMapping.extract,
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
module: `~${concept.ref.service}/ioc`,
|
|
26
|
+
namedImports: [common_1.SYMBOL_NAME],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
module: common_1.LibrariesKindMapping.logger,
|
|
30
|
+
namedImports: common_1.LoggerKindMapping.logger,
|
|
31
|
+
isTypings: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
module: common_1.LibrariesKindMapping.redis,
|
|
35
|
+
namedImports: common_1.RedisKindMapping.redis,
|
|
36
|
+
isTypings: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
module: common_1.LibrariesKindMapping.be_config,
|
|
40
|
+
namedImports: common_1.ConfigKindMapping.config,
|
|
41
|
+
isTypings: true,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
module: `~${concept.ref.service}/types`,
|
|
45
|
+
namedImports: 'ConfigEnvs',
|
|
46
|
+
isTypings: true,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
source = this._imports.addModule(source, imports);
|
|
50
|
+
source = this._variables.addVariable(source, {
|
|
51
|
+
name: 'CACHE_OPERATION',
|
|
52
|
+
value: (writer) => writer.writeLine(`'users'`),
|
|
53
|
+
isExportable: false,
|
|
54
|
+
});
|
|
55
|
+
return source.getText();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.CacheTemplate = CacheTemplate;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvsTemplate = void 0;
|
|
4
|
+
const morphix_1 = require("@terra-versity/morphix");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
class EnvsTemplate {
|
|
8
|
+
constructor(path, concept) {
|
|
9
|
+
const { libraries } = concept;
|
|
10
|
+
this._typings = new morphix_1.TypingsSculptor();
|
|
11
|
+
let source = new ts_morph_1.Project().createSourceFile(path, '', { overwrite: true });
|
|
12
|
+
this._typings.addTypings(source, {
|
|
13
|
+
name: 'ConfigEnvs',
|
|
14
|
+
body: (writer) => {
|
|
15
|
+
writer.writeLine(`{`);
|
|
16
|
+
writer.writeLine(`${common_1.EnvsKindMapping.service_name}: 'string'`);
|
|
17
|
+
writer.blankLine();
|
|
18
|
+
writer.writeLine(`${common_1.EnvsKindMapping.default_log_level}: 'string'`);
|
|
19
|
+
writer.blankLine();
|
|
20
|
+
writer.writeLine(`${common_1.EnvsKindMapping.tracer_collect_url}: 'string'`);
|
|
21
|
+
writer.writeLine(`${common_1.EnvsKindMapping.tracer_type}: 'string'`);
|
|
22
|
+
writer.writeLine(`${common_1.EnvsKindMapping.tracer_param}: 'number'`);
|
|
23
|
+
writer.writeLine(`${common_1.EnvsKindMapping.tracer_log_spans}: 'boolean'`);
|
|
24
|
+
if (libraries.scrambler) {
|
|
25
|
+
writer.blankLine();
|
|
26
|
+
writer.writeLine(`${common_1.EnvsKindMapping.scrambler_algorithm}: 'string'`);
|
|
27
|
+
writer.writeLine(`${common_1.EnvsKindMapping.scrambler_random_bytes}: 'number'`);
|
|
28
|
+
writer.writeLine(`${common_1.EnvsKindMapping.scrambler_salt}: 'number'`);
|
|
29
|
+
writer.writeLine(`${common_1.EnvsKindMapping.scrambler_access_token_minutes}: 'number'`);
|
|
30
|
+
writer.writeLine(`${common_1.EnvsKindMapping.scrambler_refresh_token_days}: 'number'`);
|
|
31
|
+
writer.writeLine(`${common_1.EnvsKindMapping.scrambler_jwt_secret}: 'string'`);
|
|
32
|
+
}
|
|
33
|
+
if (libraries.emails) {
|
|
34
|
+
writer.blankLine();
|
|
35
|
+
writer.writeLine(`${common_1.EnvsKindMapping.mail_is_secure}: 'boolean'`);
|
|
36
|
+
writer.writeLine(`${common_1.EnvsKindMapping.mail_auth_password}: 'string'`);
|
|
37
|
+
writer.writeLine(`${common_1.EnvsKindMapping.mail_auth_username}: 'string'`);
|
|
38
|
+
writer.writeLine(`${common_1.EnvsKindMapping.mail_host}: 'string'`);
|
|
39
|
+
writer.writeLine(`${common_1.EnvsKindMapping.mail_port}: 'number'`);
|
|
40
|
+
}
|
|
41
|
+
if (libraries.slack) {
|
|
42
|
+
writer.blankLine();
|
|
43
|
+
writer.writeLine(`${common_1.EnvsKindMapping.slack_secret}: 'string'`);
|
|
44
|
+
writer.writeLine(`${common_1.EnvsKindMapping.slack_token}: 'string'`);
|
|
45
|
+
writer.writeLine(`${common_1.EnvsKindMapping.slack_server_port}: 'number'`);
|
|
46
|
+
writer.writeLine(`${common_1.EnvsKindMapping.slack_server_host}: 'string'`);
|
|
47
|
+
}
|
|
48
|
+
if (libraries.telegram) {
|
|
49
|
+
writer.blankLine();
|
|
50
|
+
writer.writeLine(`${common_1.EnvsKindMapping.telegram_bot_token}: 'string'`);
|
|
51
|
+
}
|
|
52
|
+
if (libraries.redis) {
|
|
53
|
+
writer.blankLine();
|
|
54
|
+
writer.writeLine(`${common_1.EnvsKindMapping.redis_host}: 'string'`);
|
|
55
|
+
writer.writeLine(`${common_1.EnvsKindMapping.redis_port}: 'number'`);
|
|
56
|
+
writer.writeLine(`${common_1.EnvsKindMapping.redis_auth_user}: 'string'`);
|
|
57
|
+
writer.writeLine(`${common_1.EnvsKindMapping.redis_auth_password}: 'string'`);
|
|
58
|
+
}
|
|
59
|
+
if (libraries.broker) {
|
|
60
|
+
writer.blankLine();
|
|
61
|
+
writer.writeLine(`${common_1.EnvsKindMapping.broker_url}: 'string'`);
|
|
62
|
+
}
|
|
63
|
+
if (libraries.clickHouse) {
|
|
64
|
+
writer.writeLine(`${common_1.EnvsKindMapping.click_house_write_host}: 'string'`);
|
|
65
|
+
writer.writeLine(`${common_1.EnvsKindMapping.click_house_write_port}: 'number'`);
|
|
66
|
+
writer.writeLine(`${common_1.EnvsKindMapping.click_house_write_user}: 'string'`);
|
|
67
|
+
writer.writeLine(`${common_1.EnvsKindMapping.click_house_write_password}: 'string'`);
|
|
68
|
+
writer.writeLine(`${common_1.EnvsKindMapping.click_house_database}: 'string'`);
|
|
69
|
+
}
|
|
70
|
+
if (libraries.postgres) {
|
|
71
|
+
writer.blankLine();
|
|
72
|
+
writer.writeLine(`${common_1.EnvsKindMapping.postgres_write_host}: 'string'`);
|
|
73
|
+
writer.writeLine(`${common_1.EnvsKindMapping.postgres_write_port}: 'number'`);
|
|
74
|
+
writer.writeLine(`${common_1.EnvsKindMapping.postgres_write_username}: 'string'`);
|
|
75
|
+
writer.writeLine(`${common_1.EnvsKindMapping.postgres_write_password}: 'string'`);
|
|
76
|
+
writer.writeLine(`${common_1.EnvsKindMapping.postgres_database}: 'string'`);
|
|
77
|
+
}
|
|
78
|
+
if (libraries.timescale) {
|
|
79
|
+
writer.blankLine();
|
|
80
|
+
writer.writeLine(`${common_1.EnvsKindMapping.timescale_write_host}: 'string'`);
|
|
81
|
+
writer.writeLine(`${common_1.EnvsKindMapping.timescale_write_port}: 'number'`);
|
|
82
|
+
writer.writeLine(`${common_1.EnvsKindMapping.timescale_write_username}: 'string'`);
|
|
83
|
+
writer.writeLine(`${common_1.EnvsKindMapping.timescale_write_password}: 'string'`);
|
|
84
|
+
writer.writeLine(`${common_1.EnvsKindMapping.timescale_database}: 'string'`);
|
|
85
|
+
}
|
|
86
|
+
if (libraries.storix) {
|
|
87
|
+
writer.blankLine();
|
|
88
|
+
writer.writeLine(`${common_1.EnvsKindMapping.storix_aws_endpoint}: 'string'`);
|
|
89
|
+
writer.writeLine(`${common_1.EnvsKindMapping.storix_aws_region}: 'string'`);
|
|
90
|
+
writer.writeLine(`${common_1.EnvsKindMapping.storix_aws_access_id}: 'string'`);
|
|
91
|
+
writer.writeLine(`${common_1.EnvsKindMapping.storix_force_path_style}: 'boolean'`);
|
|
92
|
+
}
|
|
93
|
+
if (libraries.manager) {
|
|
94
|
+
writer.blankLine();
|
|
95
|
+
writer.writeLine(`${common_1.EnvsKindMapping.manager_host}: 'string'`);
|
|
96
|
+
writer.writeLine(`${common_1.EnvsKindMapping.manager_port}: 'number'`);
|
|
97
|
+
}
|
|
98
|
+
if (libraries.httpServer) {
|
|
99
|
+
writer.blankLine();
|
|
100
|
+
writer.writeLine(`${common_1.EnvsKindMapping.http_server_host}: 'string'`);
|
|
101
|
+
writer.writeLine(`${common_1.EnvsKindMapping.http_server_port}: 'number'`);
|
|
102
|
+
}
|
|
103
|
+
if (libraries.wsServer) {
|
|
104
|
+
writer.blankLine();
|
|
105
|
+
writer.writeLine(`${common_1.EnvsKindMapping.ws_server_host}: 'string'`);
|
|
106
|
+
writer.writeLine(`${common_1.EnvsKindMapping.ws_server_port}: 'number'`);
|
|
107
|
+
writer.writeLine(`${common_1.EnvsKindMapping.ws_gw_service_endpoint}: 'string'`);
|
|
108
|
+
}
|
|
109
|
+
writer.writeLine(`}`);
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
console.log(source.getText());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.EnvsTemplate = EnvsTemplate;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cache.template"), exports);
|
|
18
|
+
__exportStar(require("./module.template"), exports);
|
|
19
|
+
__exportStar(require("./pg-repository.template"), exports);
|
|
20
|
+
__exportStar(require("./transport.template"), exports);
|
|
21
|
+
__exportStar(require("./validator.template"), exports);
|
|
22
|
+
__exportStar(require("./index.template"), exports);
|
|
23
|
+
__exportStar(require("./ioc.template"), exports);
|
|
24
|
+
__exportStar(require("./initiator.template"), exports);
|
|
25
|
+
__exportStar(require("./sys.template"), exports);
|
|
26
|
+
__exportStar(require("./envs.template"), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexTemplate = void 0;
|
|
4
|
+
const morphix_1 = require("@terra-versity/morphix");
|
|
5
|
+
const ts_morph_1 = require("ts-morph");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
class IndexTemplate {
|
|
8
|
+
constructor(path) {
|
|
9
|
+
this._imports = new morphix_1.ImportsSculptor();
|
|
10
|
+
this._variables = new morphix_1.VariablesSculptor();
|
|
11
|
+
this._path = path;
|
|
12
|
+
}
|
|
13
|
+
generate() {
|
|
14
|
+
const source = new ts_morph_1.Project().createSourceFile(this._path, '', { overwrite: true });
|
|
15
|
+
this._imports.addModule(source, [{ module: './initiator', namedImports: 'Initiator' }]);
|
|
16
|
+
this._variables.addVariable(source, {
|
|
17
|
+
name: 'initiator',
|
|
18
|
+
value: (writer) => {
|
|
19
|
+
writer.blankLine();
|
|
20
|
+
writer.writeLine(`container.get<Initiator>(${common_1.SYMBOL_NAME}.Initiator)`);
|
|
21
|
+
writer.blankLine();
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
this._variables.addStatement(source, (writer) => {
|
|
25
|
+
writer.writeLine('void initiator');
|
|
26
|
+
writer.writeLine('.init()');
|
|
27
|
+
writer.writeLine('.then(async () => {');
|
|
28
|
+
writer.writeLine('await initiator.healthcheck()');
|
|
29
|
+
writer.writeLine('})');
|
|
30
|
+
writer.writeLine('.catch(async (e) => {');
|
|
31
|
+
writer.writeLine('console.error(e)');
|
|
32
|
+
writer.writeLine('await initiator.destroy()');
|
|
33
|
+
writer.writeLine('})');
|
|
34
|
+
});
|
|
35
|
+
source.saveSync();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.IndexTemplate = IndexTemplate;
|