easyfeat 1.0.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/LICENSE +21 -0
- package/README.md +323 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +44 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +216 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/delete.d.ts +2 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +36 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/file-utils.d.ts +42 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +113 -0
- package/dist/utils/file-utils.js.map +1 -0
- package/dist/utils/route-utils.d.ts +3 -0
- package/dist/utils/route-utils.d.ts.map +1 -0
- package/dist/utils/route-utils.js +139 -0
- package/dist/utils/route-utils.js.map +1 -0
- package/dist/utils/template-generator.d.ts +29 -0
- package/dist/utils/template-generator.d.ts.map +1 -0
- package/dist/utils/template-generator.js +419 -0
- package/dist/utils/template-generator.js.map +1 -0
- package/package.json +56 -0
- package/templates/base.repository.interface.ts +9 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";;;;;AAIA,sCA8BC;AAlCD,kDAA0B;AAC1B,oDAAwF;AACxF,sDAAqD;AAErD,SAAgB,aAAa,CAAC,WAAmB;IAC7C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAEpD,qCAAqC;IACrC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,wBAAW,EAAC,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;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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("./commands/create"), exports);
|
|
18
|
+
__exportStar(require("./commands/delete"), exports);
|
|
19
|
+
__exportStar(require("./utils/template-generator"), exports);
|
|
20
|
+
__exportStar(require("./utils/file-utils"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,oDAAkC;AAClC,6DAA2C;AAC3C,qDAAmC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface CaseConversions {
|
|
2
|
+
kebab: string;
|
|
3
|
+
pascal: string;
|
|
4
|
+
camel: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Convert a feature name to different cases
|
|
8
|
+
*/
|
|
9
|
+
export declare function convertCase(name: string): CaseConversions;
|
|
10
|
+
/**
|
|
11
|
+
* Ensure directory exists, create if it doesn't
|
|
12
|
+
*/
|
|
13
|
+
export declare function ensureDir(dirPath: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Remove directory recursively
|
|
16
|
+
*/
|
|
17
|
+
export declare function removeDir(dirPath: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Write file with content
|
|
20
|
+
*/
|
|
21
|
+
export declare function writeFile(filePath: string, content: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Read file content
|
|
24
|
+
*/
|
|
25
|
+
export declare function readFile(filePath: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Check if file exists
|
|
28
|
+
*/
|
|
29
|
+
export declare function fileExists(filePath: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get the target directory for feature
|
|
32
|
+
*/
|
|
33
|
+
export declare function getFeatureDir(featureName: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get routes directory
|
|
36
|
+
*/
|
|
37
|
+
export declare function getRoutesDir(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get core interfaces directory
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCoreInterfacesDir(): string;
|
|
42
|
+
//# sourceMappingURL=file-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CASzD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAI/C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAI/C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIjE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.convertCase = convertCase;
|
|
37
|
+
exports.ensureDir = ensureDir;
|
|
38
|
+
exports.removeDir = removeDir;
|
|
39
|
+
exports.writeFile = writeFile;
|
|
40
|
+
exports.readFile = readFile;
|
|
41
|
+
exports.fileExists = fileExists;
|
|
42
|
+
exports.getFeatureDir = getFeatureDir;
|
|
43
|
+
exports.getRoutesDir = getRoutesDir;
|
|
44
|
+
exports.getCoreInterfacesDir = getCoreInterfacesDir;
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
/**
|
|
48
|
+
* Convert a feature name to different cases
|
|
49
|
+
*/
|
|
50
|
+
function convertCase(name) {
|
|
51
|
+
const kebab = name.toLowerCase().replace(/\s+/g, '-');
|
|
52
|
+
const pascal = name.charAt(0).toUpperCase() +
|
|
53
|
+
name.slice(1)
|
|
54
|
+
.toLowerCase()
|
|
55
|
+
.replace(/[-\s](\w)/g, (_, c) => c.toUpperCase());
|
|
56
|
+
const camel = pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
57
|
+
return { kebab, pascal, camel };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Ensure directory exists, create if it doesn't
|
|
61
|
+
*/
|
|
62
|
+
function ensureDir(dirPath) {
|
|
63
|
+
if (!fs.existsSync(dirPath)) {
|
|
64
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Remove directory recursively
|
|
69
|
+
*/
|
|
70
|
+
function removeDir(dirPath) {
|
|
71
|
+
if (fs.existsSync(dirPath)) {
|
|
72
|
+
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Write file with content
|
|
77
|
+
*/
|
|
78
|
+
function writeFile(filePath, content) {
|
|
79
|
+
const dir = path.dirname(filePath);
|
|
80
|
+
ensureDir(dir);
|
|
81
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Read file content
|
|
85
|
+
*/
|
|
86
|
+
function readFile(filePath) {
|
|
87
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if file exists
|
|
91
|
+
*/
|
|
92
|
+
function fileExists(filePath) {
|
|
93
|
+
return fs.existsSync(filePath);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the target directory for feature
|
|
97
|
+
*/
|
|
98
|
+
function getFeatureDir(featureName) {
|
|
99
|
+
return path.join(process.cwd(), 'src', 'features', featureName);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get routes directory
|
|
103
|
+
*/
|
|
104
|
+
function getRoutesDir() {
|
|
105
|
+
return path.join(process.cwd(), 'src', 'routes');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get core interfaces directory
|
|
109
|
+
*/
|
|
110
|
+
function getCoreInterfacesDir() {
|
|
111
|
+
return path.join(process.cwd(), 'src', 'core', 'interfaces');
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=file-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/utils/file-utils.ts"],"names":[],"mappings":";;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
"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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.updateRoutes = updateRoutes;
|
|
37
|
+
exports.cleanupRoutes = cleanupRoutes;
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const file_utils_1 = require("./file-utils");
|
|
40
|
+
function updateRoutes(featureName, version = 'v1') {
|
|
41
|
+
const routesDir = (0, file_utils_1.getRoutesDir)();
|
|
42
|
+
const versionDir = path.join(routesDir, version);
|
|
43
|
+
const versionIndexPath = path.join(versionDir, 'index.ts');
|
|
44
|
+
// Create version directory if it doesn't exist
|
|
45
|
+
if (!(0, file_utils_1.fileExists)(versionDir)) {
|
|
46
|
+
(0, file_utils_1.ensureDir)(versionDir);
|
|
47
|
+
const initialVersionContent = `import express from 'express';
|
|
48
|
+
|
|
49
|
+
const router = express.Router();
|
|
50
|
+
|
|
51
|
+
export default router;
|
|
52
|
+
`;
|
|
53
|
+
(0, file_utils_1.writeFile)(versionIndexPath, initialVersionContent);
|
|
54
|
+
}
|
|
55
|
+
// Update version index file
|
|
56
|
+
let versionContent = (0, file_utils_1.fileExists)(versionIndexPath)
|
|
57
|
+
? (0, file_utils_1.readFile)(versionIndexPath)
|
|
58
|
+
: `import express from 'express';\n\nconst router = express.Router();\n\nexport default router;\n`;
|
|
59
|
+
// Add import statement if not exists
|
|
60
|
+
const importStatement = `import ${featureName}Routes from '../../features/${featureName}/routes/${featureName}.routes';`;
|
|
61
|
+
if (!versionContent.includes(importStatement)) {
|
|
62
|
+
const lastImportIndex = versionContent.lastIndexOf('import');
|
|
63
|
+
const insertPosition = lastImportIndex === -1
|
|
64
|
+
? 0
|
|
65
|
+
: versionContent.indexOf(';', lastImportIndex) + 1;
|
|
66
|
+
const beforeImport = versionContent.substring(0, insertPosition);
|
|
67
|
+
const afterImport = versionContent.substring(insertPosition);
|
|
68
|
+
versionContent =
|
|
69
|
+
beforeImport +
|
|
70
|
+
(insertPosition ? '\n' : '') +
|
|
71
|
+
importStatement +
|
|
72
|
+
afterImport;
|
|
73
|
+
}
|
|
74
|
+
// Add route registration if not exists
|
|
75
|
+
const routeRegistration = `router.use('/${featureName}', ${featureName}Routes);`;
|
|
76
|
+
if (!versionContent.includes(routeRegistration)) {
|
|
77
|
+
const exportIndex = versionContent.lastIndexOf('export');
|
|
78
|
+
const beforeExport = versionContent.substring(0, exportIndex);
|
|
79
|
+
const afterExport = versionContent.substring(exportIndex);
|
|
80
|
+
versionContent = beforeExport + routeRegistration + '\n\n' + afterExport;
|
|
81
|
+
}
|
|
82
|
+
// Write updated version content
|
|
83
|
+
(0, file_utils_1.writeFile)(versionIndexPath, versionContent);
|
|
84
|
+
// Update main routes index file
|
|
85
|
+
const mainIndexPath = path.join(routesDir, 'index.ts');
|
|
86
|
+
let mainContent = (0, file_utils_1.fileExists)(mainIndexPath)
|
|
87
|
+
? (0, file_utils_1.readFile)(mainIndexPath)
|
|
88
|
+
: `import express from 'express';\n\nconst router = express.Router();\n\nexport default router;\n`;
|
|
89
|
+
// Add version import if not exists
|
|
90
|
+
const versionImport = `import ${version}Routes from './${version}';`;
|
|
91
|
+
if (!mainContent.includes(versionImport)) {
|
|
92
|
+
const lastImportIndex = mainContent.lastIndexOf('import');
|
|
93
|
+
const insertPosition = lastImportIndex === -1
|
|
94
|
+
? 0
|
|
95
|
+
: mainContent.indexOf(';', lastImportIndex) + 1;
|
|
96
|
+
const beforeImport = mainContent.substring(0, insertPosition);
|
|
97
|
+
const afterImport = mainContent.substring(insertPosition);
|
|
98
|
+
mainContent =
|
|
99
|
+
beforeImport + (insertPosition ? '\n' : '') + versionImport + afterImport;
|
|
100
|
+
}
|
|
101
|
+
// Add version route registration if not exists
|
|
102
|
+
const versionRegistration = `router.use('/${version}', ${version}Routes);`;
|
|
103
|
+
if (!mainContent.includes(versionRegistration)) {
|
|
104
|
+
const exportIndex = mainContent.lastIndexOf('export');
|
|
105
|
+
const beforeExport = mainContent.substring(0, exportIndex);
|
|
106
|
+
const afterExport = mainContent.substring(exportIndex);
|
|
107
|
+
mainContent = beforeExport + versionRegistration + '\n\n' + afterExport;
|
|
108
|
+
}
|
|
109
|
+
// Write updated main content
|
|
110
|
+
(0, file_utils_1.writeFile)(mainIndexPath, mainContent);
|
|
111
|
+
}
|
|
112
|
+
function cleanupRoutes(featureName) {
|
|
113
|
+
const routesDir = (0, file_utils_1.getRoutesDir)();
|
|
114
|
+
if (!(0, file_utils_1.fileExists)(routesDir)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Get all version directories
|
|
118
|
+
const fs = require('fs');
|
|
119
|
+
const versionDirs = fs
|
|
120
|
+
.readdirSync(routesDir)
|
|
121
|
+
.filter((dir) => dir.startsWith('v') &&
|
|
122
|
+
fs.statSync(path.join(routesDir, dir)).isDirectory());
|
|
123
|
+
versionDirs.forEach((version) => {
|
|
124
|
+
const versionIndexPath = path.join(routesDir, version, 'index.ts');
|
|
125
|
+
if ((0, file_utils_1.fileExists)(versionIndexPath)) {
|
|
126
|
+
let content = (0, file_utils_1.readFile)(versionIndexPath);
|
|
127
|
+
// Remove import statement
|
|
128
|
+
const importRegex = new RegExp(`import\\s+${featureName}Routes\\s+from\\s+['"]../../features/${featureName}/routes/${featureName}.routes['"];?\\n?`, 'g');
|
|
129
|
+
content = content.replace(importRegex, '');
|
|
130
|
+
// Remove route registration
|
|
131
|
+
const routeRegex = new RegExp(`\\s*router\\.use\\s*\\(['"]/${featureName}['"]\\s*,\\s*${featureName}Routes\\);?\\n?`, 'g');
|
|
132
|
+
content = content.replace(routeRegex, '');
|
|
133
|
+
// Clean up extra newlines
|
|
134
|
+
content = content.replace(/\n{3,}/g, '\n\n');
|
|
135
|
+
(0, file_utils_1.writeFile)(versionIndexPath, content);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=route-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-utils.js","sourceRoot":"","sources":["../../src/utils/route-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,oCAyFC;AAED,sCA0CC;AAxID,2CAA6B;AAC7B,6CAAwF;AAExF,SAAgB,YAAY,CACxB,WAAmB,EACnB,UAAkB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AE,CAC3D,CAAC;IAEN,WAAW,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE;QACpC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACnE,IAAI,IAAA,uBAAU,EAAC,gBAAgB,CAAC,EAAE,CAAC;YAC/B,IAAI,OAAO,GAAG,IAAA,qBAAQ,EAAC,gBAAgB,CAAC,CAAC;YAEzC,0BAA0B;YAC1B,MAAM,WAAW,GAAG,IAAI,MAAM,CAC1B,aAAa,WAAW,wCAAwC,WAAW,WAAW,WAAW,mBAAmB,EACpH,GAAG,CACN,CAAC;YACF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAE3C,4BAA4B;YAC5B,MAAM,UAAU,GAAG,IAAI,MAAM,CACzB,+BAA+B,WAAW,gBAAgB,WAAW,iBAAiB,EACtF,GAAG,CACN,CAAC;YACF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAE1C,0BAA0B;YAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAE7C,IAAA,sBAAS,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface TemplateContext {
|
|
2
|
+
featureNameKebab: string;
|
|
3
|
+
featureNamePascal: string;
|
|
4
|
+
featureNameCamel: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const templates: {
|
|
7
|
+
baseRepositoryInterface: () => string;
|
|
8
|
+
entity: (ctx: TemplateContext) => string;
|
|
9
|
+
entityMinimal: (ctx: TemplateContext) => string;
|
|
10
|
+
repositoryInterface: (ctx: TemplateContext) => string;
|
|
11
|
+
repositoryInterfaceMinimal: (ctx: TemplateContext) => string;
|
|
12
|
+
repository: (ctx: TemplateContext) => string;
|
|
13
|
+
repositoryMinimal: (ctx: TemplateContext) => string;
|
|
14
|
+
mapper: (ctx: TemplateContext) => string;
|
|
15
|
+
validation: (ctx: TemplateContext) => string;
|
|
16
|
+
createDto: (ctx: TemplateContext) => string;
|
|
17
|
+
updateDto: (ctx: TemplateContext) => string;
|
|
18
|
+
model: (ctx: TemplateContext) => string;
|
|
19
|
+
modelMinimal: (ctx: TemplateContext) => string;
|
|
20
|
+
serviceInterface: (ctx: TemplateContext) => string;
|
|
21
|
+
serviceInterfaceMinimal: (ctx: TemplateContext) => string;
|
|
22
|
+
service: (ctx: TemplateContext) => string;
|
|
23
|
+
serviceMinimal: (ctx: TemplateContext) => string;
|
|
24
|
+
controller: (ctx: TemplateContext) => string;
|
|
25
|
+
controllerMinimal: (ctx: TemplateContext) => string;
|
|
26
|
+
routes: (ctx: TemplateContext) => string;
|
|
27
|
+
routesMinimal: (ctx: TemplateContext) => string;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=template-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-generator.d.ts","sourceRoot":"","sources":["../../src/utils/template-generator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS;;kBAWJ,eAAe;yBAkBR,eAAe;+BAUT,eAAe;sCAOR,eAAe;sBAK/B,eAAe;6BAgDR,eAAe;kBAkC1B,eAAe;sBA+BX,eAAe;qBA2BhB,eAAe;qBAcf,eAAe;iBAcnB,eAAe;wBAuBR,eAAe;4BAaX,eAAe;mCAYR,eAAe;mBAM/B,eAAe;0BAqCR,eAAe;sBAenB,eAAe;6BA6ER,eAAe;kBAW1B,eAAe;yBAcR,eAAe;CAOvC,CAAC"}
|