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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nitesh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# EasyFeat š
|
|
2
|
+
|
|
3
|
+
A powerful CLI tool to quickly scaffold clean code features with repository pattern, services, controllers, and more for Node.js/TypeScript backend applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- šļø **Clean Architecture**: Generates features following clean code principles
|
|
8
|
+
- š¦ **Repository Pattern**: Built-in support for repository pattern with base interfaces
|
|
9
|
+
- šÆ **TypeScript First**: Fully typed code generation
|
|
10
|
+
- š **Express.js Ready**: Controllers and routes ready for Express.js
|
|
11
|
+
- šļø **MongoDB/Mongoose**: Pre-configured Mongoose models and mappers
|
|
12
|
+
- ā
**Validation**: Joi validation schemas included
|
|
13
|
+
- šØ **Flexible**: Choose between full or minimal feature scaffolding
|
|
14
|
+
- š **Version Support**: API versioning support out of the box
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Option 1: Global Installation
|
|
19
|
+
|
|
20
|
+
Install globally to use `easyfeat` command anywhere:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g easyfeat
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then use it:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
easyfeat create user
|
|
30
|
+
easyfeat delete product
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Option 2: Project Dependency
|
|
34
|
+
|
|
35
|
+
Install in your project:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install --save-dev easyfeat
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then use with `npx`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx easyfeat create user
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Or add to your package.json scripts:**
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"scripts": {
|
|
52
|
+
"create-feature": "easyfeat create",
|
|
53
|
+
"delete-feature": "easyfeat delete"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Now you can run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm run create-feature user
|
|
62
|
+
npm run delete-feature product
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Option 3: No Installation (npx)
|
|
66
|
+
|
|
67
|
+
Use directly without installing:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx easyfeat create user
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This downloads and runs the latest version temporarily.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
### Create Your First Feature
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
easyfeat create user
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
This creates a complete user feature with entity, repository, service, controller, routes, DTOs, validation, and more.
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
### Create Feature
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Full feature (recommended)
|
|
93
|
+
easyfeat create user
|
|
94
|
+
|
|
95
|
+
# Minimal feature
|
|
96
|
+
easyfeat create user --minimal
|
|
97
|
+
easyfeat create user -m
|
|
98
|
+
|
|
99
|
+
# With API version
|
|
100
|
+
easyfeat create user --version v2
|
|
101
|
+
easyfeat create user -v v2
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Delete Feature
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
easyfeat delete user
|
|
108
|
+
# or
|
|
109
|
+
easyfeat remove user
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Help
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
easyfeat --help
|
|
116
|
+
easyfeat create --help
|
|
117
|
+
easyfeat delete --help
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Generated Structure
|
|
121
|
+
|
|
122
|
+
### Full Feature
|
|
123
|
+
|
|
124
|
+
When you run `easyfeat create user`, it generates:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
src/
|
|
128
|
+
āāā core/
|
|
129
|
+
ā āāā interfaces/
|
|
130
|
+
ā āāā base.repository.interface.ts
|
|
131
|
+
āāā features/
|
|
132
|
+
ā āāā user/
|
|
133
|
+
ā āāā entities/
|
|
134
|
+
ā ā āāā user.entity.ts
|
|
135
|
+
ā āāā interfaces/
|
|
136
|
+
ā ā āāā i-user.repository.ts
|
|
137
|
+
ā ā āāā i-user.service.ts
|
|
138
|
+
ā āāā repositories/
|
|
139
|
+
ā ā āāā user.repository.ts
|
|
140
|
+
ā āāā mappers/
|
|
141
|
+
ā ā āāā user.mapper.ts
|
|
142
|
+
ā āāā models/
|
|
143
|
+
ā ā āāā user.model.ts
|
|
144
|
+
ā āāā dtos/
|
|
145
|
+
ā ā āāā create-user.dto.ts
|
|
146
|
+
ā ā āāā update-user.dto.ts
|
|
147
|
+
ā āāā services/
|
|
148
|
+
ā ā āāā user.service.ts
|
|
149
|
+
ā āāā controllers/
|
|
150
|
+
ā ā āāā user.controller.ts
|
|
151
|
+
ā āāā routes/
|
|
152
|
+
ā ā āāā user.routes.ts
|
|
153
|
+
ā āāā validations/
|
|
154
|
+
ā āāā user.validation.ts
|
|
155
|
+
āāā routes/
|
|
156
|
+
āāā index.ts
|
|
157
|
+
āāā v1/
|
|
158
|
+
āāā index.ts
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Minimal Feature
|
|
162
|
+
|
|
163
|
+
The `--minimal` flag creates a basic structure with implementation stubs, giving you more control over the implementation.
|
|
164
|
+
|
|
165
|
+
## Examples
|
|
166
|
+
|
|
167
|
+
### Basic Usage
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Create a user management feature
|
|
171
|
+
easyfeat create user
|
|
172
|
+
|
|
173
|
+
# Create an authentication feature with minimal setup
|
|
174
|
+
easyfeat create auth --minimal
|
|
175
|
+
|
|
176
|
+
# Create a product feature for API v2
|
|
177
|
+
easyfeat create product --version v2
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### E-commerce Application
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
easyfeat create product
|
|
184
|
+
easyfeat create order
|
|
185
|
+
easyfeat create payment
|
|
186
|
+
easyfeat create cart
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Blog Application
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
easyfeat create post
|
|
193
|
+
easyfeat create comment
|
|
194
|
+
easyfeat create category
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Microservices
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Auth service
|
|
201
|
+
easyfeat create authentication
|
|
202
|
+
easyfeat create authorization
|
|
203
|
+
|
|
204
|
+
# Product service
|
|
205
|
+
easyfeat create product
|
|
206
|
+
easyfeat create inventory
|
|
207
|
+
|
|
208
|
+
# Order service
|
|
209
|
+
easyfeat create order
|
|
210
|
+
easyfeat create shipment
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Customization
|
|
214
|
+
|
|
215
|
+
After generating a feature, customize these files:
|
|
216
|
+
|
|
217
|
+
1. **Entity** (`entities/*.entity.ts`) - Add your domain properties
|
|
218
|
+
2. **Model** (`models/*.model.ts`) - Define MongoDB schema
|
|
219
|
+
3. **DTOs** (`dtos/*.dto.ts`) - Add data transfer objects
|
|
220
|
+
4. **Validation** (`validations/*.validation.ts`) - Add validation rules
|
|
221
|
+
5. **Service** (`services/*.service.ts`) - Implement business logic
|
|
222
|
+
6. **Controller** (`controllers/*.controller.ts`) - Customize API handlers
|
|
223
|
+
7. **Mapper** (`mappers/*.mapper.ts`) - Update entity/model transformations
|
|
224
|
+
|
|
225
|
+
### Example: Customizing User Entity
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
export class User {
|
|
229
|
+
id!: string;
|
|
230
|
+
email!: string;
|
|
231
|
+
username!: string;
|
|
232
|
+
firstName!: string;
|
|
233
|
+
lastName!: string;
|
|
234
|
+
isActive!: boolean;
|
|
235
|
+
createdAt!: Date;
|
|
236
|
+
updatedAt!: Date;
|
|
237
|
+
|
|
238
|
+
constructor(data: Partial<User>) {
|
|
239
|
+
Object.assign(this, data);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
get fullName(): string {
|
|
243
|
+
return `${this.firstName} ${this.lastName}`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
toJSON() {
|
|
247
|
+
return {
|
|
248
|
+
id: this.id,
|
|
249
|
+
email: this.email,
|
|
250
|
+
username: this.username,
|
|
251
|
+
fullName: this.fullName,
|
|
252
|
+
isActive: this.isActive,
|
|
253
|
+
createdAt: this.createdAt,
|
|
254
|
+
updatedAt: this.updatedAt
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Example: Customizing Model Schema
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
const UserSchema = new Schema({
|
|
264
|
+
email: { type: String, required: true, unique: true, lowercase: true },
|
|
265
|
+
username: { type: String, required: true, unique: true },
|
|
266
|
+
firstName: { type: String, required: true },
|
|
267
|
+
lastName: { type: String, required: true },
|
|
268
|
+
isActive: { type: Boolean, default: true }
|
|
269
|
+
}, { timestamps: true });
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Integration with Express
|
|
273
|
+
|
|
274
|
+
FeatForge automatically updates your route files. Just import and use in your app:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import express from 'express';
|
|
278
|
+
import routes from './routes';
|
|
279
|
+
|
|
280
|
+
const app = express();
|
|
281
|
+
|
|
282
|
+
app.use(express.json());
|
|
283
|
+
app.use('/api', routes);
|
|
284
|
+
|
|
285
|
+
app.listen(3000, () => {
|
|
286
|
+
console.log('Server running on port 3000');
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Architecture
|
|
291
|
+
|
|
292
|
+
EasyFeat generates code following these principles:
|
|
293
|
+
|
|
294
|
+
1. **Separation of Concerns** - Each layer has a single responsibility
|
|
295
|
+
2. **Dependency Inversion** - Interfaces between layers
|
|
296
|
+
3. **Repository Pattern** - Data access abstraction
|
|
297
|
+
4. **DTO Pattern** - Data transfer objects for API boundaries
|
|
298
|
+
5. **Mapper Pattern** - Transform between domain and data models
|
|
299
|
+
6. **Validation Layer** - Input validation with Joi
|
|
300
|
+
|
|
301
|
+
## Requirements
|
|
302
|
+
|
|
303
|
+
- Node.js >= 14.0.0
|
|
304
|
+
- TypeScript project
|
|
305
|
+
- Express.js (for generated routes)
|
|
306
|
+
- Mongoose (for generated models)
|
|
307
|
+
- Joi (for generated validations)
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Contributions are welcome! Please check out [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
MIT Ā© Nitesh
|
|
316
|
+
|
|
317
|
+
## Support
|
|
318
|
+
|
|
319
|
+
If you encounter any issues or have questions, please file an issue on the [GitHub repository](https://github.com/yourusername/easyfeat).
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
Made with ā¤ļø by Nitesh
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const create_1 = require("./commands/create");
|
|
9
|
+
const delete_1 = require("./commands/delete");
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const program = new commander_1.Command();
|
|
12
|
+
program
|
|
13
|
+
.name('easyfeat')
|
|
14
|
+
.description('A CLI tool to quickly scaffold clean code features')
|
|
15
|
+
.version('1.0.0');
|
|
16
|
+
program
|
|
17
|
+
.command('create <feature-name>')
|
|
18
|
+
.description('Create a new feature with clean code architecture')
|
|
19
|
+
.option('-v, --version <version>', 'API version (default: v1)', 'v1')
|
|
20
|
+
.option('-m, --minimal', 'Create minimal feature structure', false)
|
|
21
|
+
.action((featureName, options) => {
|
|
22
|
+
try {
|
|
23
|
+
(0, create_1.createFeature)(featureName, options.version, options.minimal);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
program
|
|
31
|
+
.command('delete <feature-name>')
|
|
32
|
+
.alias('remove')
|
|
33
|
+
.description('Delete an existing feature')
|
|
34
|
+
.action((featureName) => {
|
|
35
|
+
try {
|
|
36
|
+
(0, delete_1.deleteFeature)(featureName);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
program.parse();
|
|
44
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,8CAAkD;AAClD,8CAAkD;AAClD,kDAA0B;AAE1B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,oDAAoD,CAAC;KACjE,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,OAAO;KACF,OAAO,CAAC,uBAAuB,CAAC;KAChC,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,yBAAyB,EAAE,2BAA2B,EAAE,IAAI,CAAC;KACpE,MAAM,CAAC,eAAe,EAAE,kCAAkC,EAAE,KAAK,CAAC;KAClE,MAAM,CAAC,CAAC,WAAmB,EAAE,OAA8C,EAAE,EAAE;IAC5E,IAAI,CAAC;QACD,IAAA,sBAAa,EAAC,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC7F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO;KACF,OAAO,CAAC,uBAAuB,CAAC;KAChC,KAAK,CAAC,QAAQ,CAAC;KACf,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,CAAC,WAAmB,EAAE,EAAE;IAC5B,IAAI,CAAC;QACD,IAAA,sBAAa,EAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QAC7F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAkBA,wBAAgB,aAAa,CACzB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,MAAa,EACtB,OAAO,GAAE,OAAe,GACzB,IAAI,CAqLN"}
|
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createFeature = createFeature;
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const file_utils_1 = require("../utils/file-utils");
|
|
43
|
+
const template_generator_1 = require("../utils/template-generator");
|
|
44
|
+
const route_utils_1 = require("../utils/route-utils");
|
|
45
|
+
function createFeature(featureName, version = 'v1', minimal = false) {
|
|
46
|
+
console.log(chalk_1.default.blue('š Creating feature...'));
|
|
47
|
+
// Convert feature name to different cases
|
|
48
|
+
const { kebab, pascal, camel } = (0, file_utils_1.convertCase)(featureName);
|
|
49
|
+
const featureDir = (0, file_utils_1.getFeatureDir)(kebab);
|
|
50
|
+
// Check if feature already exists
|
|
51
|
+
if ((0, file_utils_1.fileExists)(featureDir)) {
|
|
52
|
+
throw new Error(`Feature '${kebab}' already exists!`);
|
|
53
|
+
}
|
|
54
|
+
console.log(chalk_1.default.gray(`Feature name: ${pascal}`));
|
|
55
|
+
console.log(chalk_1.default.gray(`Version: ${version}`));
|
|
56
|
+
console.log(chalk_1.default.gray(`Mode: ${minimal ? 'minimal' : 'full'}`));
|
|
57
|
+
const ctx = {
|
|
58
|
+
featureNameKebab: kebab,
|
|
59
|
+
featureNamePascal: pascal,
|
|
60
|
+
featureNameCamel: camel,
|
|
61
|
+
};
|
|
62
|
+
// Create directories
|
|
63
|
+
const directories = minimal
|
|
64
|
+
? [
|
|
65
|
+
'entities',
|
|
66
|
+
'models',
|
|
67
|
+
'services',
|
|
68
|
+
'controllers',
|
|
69
|
+
'routes',
|
|
70
|
+
'interfaces',
|
|
71
|
+
'repositories',
|
|
72
|
+
]
|
|
73
|
+
: [
|
|
74
|
+
'entities',
|
|
75
|
+
'dtos',
|
|
76
|
+
'models',
|
|
77
|
+
'services',
|
|
78
|
+
'controllers',
|
|
79
|
+
'routes',
|
|
80
|
+
'interfaces',
|
|
81
|
+
'repositories',
|
|
82
|
+
'mappers',
|
|
83
|
+
'validations',
|
|
84
|
+
];
|
|
85
|
+
console.log(chalk_1.default.blue('\nš Creating directories...'));
|
|
86
|
+
directories.forEach((dir) => {
|
|
87
|
+
const dirPath = path.join(featureDir, dir);
|
|
88
|
+
(0, file_utils_1.ensureDir)(dirPath);
|
|
89
|
+
console.log(chalk_1.default.green(` ā ${dir}/`));
|
|
90
|
+
});
|
|
91
|
+
// Ensure base repository interface exists
|
|
92
|
+
const baseRepoDir = (0, file_utils_1.getCoreInterfacesDir)();
|
|
93
|
+
const baseRepoPath = path.join(baseRepoDir, 'base.repository.interface.ts');
|
|
94
|
+
if (!(0, file_utils_1.fileExists)(baseRepoPath)) {
|
|
95
|
+
(0, file_utils_1.ensureDir)(baseRepoDir);
|
|
96
|
+
(0, file_utils_1.writeFile)(baseRepoPath, template_generator_1.templates.baseRepositoryInterface());
|
|
97
|
+
console.log(chalk_1.default.yellow('\nš Created base repository interface'));
|
|
98
|
+
}
|
|
99
|
+
// Create files with templates
|
|
100
|
+
const files = minimal
|
|
101
|
+
? [
|
|
102
|
+
{
|
|
103
|
+
path: path.join(featureDir, 'entities', `${kebab}.entity.ts`),
|
|
104
|
+
content: template_generator_1.templates.entityMinimal(ctx),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
path: path.join(featureDir, 'interfaces', `i-${kebab}.repository.ts`),
|
|
108
|
+
content: template_generator_1.templates.repositoryInterfaceMinimal(ctx),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
path: path.join(featureDir, 'interfaces', `i-${kebab}.service.ts`),
|
|
112
|
+
content: template_generator_1.templates.serviceInterfaceMinimal(ctx),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
path: path.join(featureDir, 'repositories', `${kebab}.repository.ts`),
|
|
116
|
+
content: template_generator_1.templates.repositoryMinimal(ctx),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
path: path.join(featureDir, 'models', `${kebab}.model.ts`),
|
|
120
|
+
content: template_generator_1.templates.modelMinimal(ctx),
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
path: path.join(featureDir, 'services', `${kebab}.service.ts`),
|
|
124
|
+
content: template_generator_1.templates.serviceMinimal(ctx),
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
path: path.join(featureDir, 'controllers', `${kebab}.controller.ts`),
|
|
128
|
+
content: template_generator_1.templates.controllerMinimal(ctx),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
path: path.join(featureDir, 'routes', `${kebab}.routes.ts`),
|
|
132
|
+
content: template_generator_1.templates.routesMinimal(ctx),
|
|
133
|
+
},
|
|
134
|
+
]
|
|
135
|
+
: [
|
|
136
|
+
{
|
|
137
|
+
path: path.join(featureDir, 'entities', `${kebab}.entity.ts`),
|
|
138
|
+
content: template_generator_1.templates.entity(ctx),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
path: path.join(featureDir, 'interfaces', `i-${kebab}.repository.ts`),
|
|
142
|
+
content: template_generator_1.templates.repositoryInterface(ctx),
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
path: path.join(featureDir, 'interfaces', `i-${kebab}.service.ts`),
|
|
146
|
+
content: template_generator_1.templates.serviceInterface(ctx),
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
path: path.join(featureDir, 'repositories', `${kebab}.repository.ts`),
|
|
150
|
+
content: template_generator_1.templates.repository(ctx),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
path: path.join(featureDir, 'mappers', `${kebab}.mapper.ts`),
|
|
154
|
+
content: template_generator_1.templates.mapper(ctx),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
path: path.join(featureDir, 'dtos', `create-${kebab}.dto.ts`),
|
|
158
|
+
content: template_generator_1.templates.createDto(ctx),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
path: path.join(featureDir, 'dtos', `update-${kebab}.dto.ts`),
|
|
162
|
+
content: template_generator_1.templates.updateDto(ctx),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
path: path.join(featureDir, 'models', `${kebab}.model.ts`),
|
|
166
|
+
content: template_generator_1.templates.model(ctx),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
path: path.join(featureDir, 'services', `${kebab}.service.ts`),
|
|
170
|
+
content: template_generator_1.templates.service(ctx),
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
path: path.join(featureDir, 'controllers', `${kebab}.controller.ts`),
|
|
174
|
+
content: template_generator_1.templates.controller(ctx),
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
path: path.join(featureDir, 'routes', `${kebab}.routes.ts`),
|
|
178
|
+
content: template_generator_1.templates.routes(ctx),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
path: path.join(featureDir, 'validations', `${kebab}.validation.ts`),
|
|
182
|
+
content: template_generator_1.templates.validation(ctx),
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
console.log(chalk_1.default.blue('\nš Creating files...'));
|
|
186
|
+
files.forEach((file) => {
|
|
187
|
+
(0, file_utils_1.writeFile)(file.path, file.content);
|
|
188
|
+
const fileName = path.basename(file.path);
|
|
189
|
+
console.log(chalk_1.default.green(` ā ${fileName}`));
|
|
190
|
+
});
|
|
191
|
+
// Update routes
|
|
192
|
+
console.log(chalk_1.default.blue('\nš Updating routes...'));
|
|
193
|
+
try {
|
|
194
|
+
(0, route_utils_1.updateRoutes)(kebab, version);
|
|
195
|
+
console.log(chalk_1.default.green(' ā Routes updated'));
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
console.log(chalk_1.default.yellow(' ā Could not update routes (may need to be done manually)'));
|
|
199
|
+
}
|
|
200
|
+
// Success message
|
|
201
|
+
console.log(chalk_1.default.green.bold(`\n⨠Feature '${pascal}' created successfully!`));
|
|
202
|
+
console.log(chalk_1.default.blue('\nš Next steps:'));
|
|
203
|
+
console.log(chalk_1.default.gray(` 1. Add entity fields in: entities/${kebab}.entity.ts`));
|
|
204
|
+
if (!minimal) {
|
|
205
|
+
console.log(chalk_1.default.gray(` 2. Update mapper in: mappers/${kebab}.mapper.ts`));
|
|
206
|
+
console.log(chalk_1.default.gray(` 3. Add schema fields in: models/${kebab}.model.ts`));
|
|
207
|
+
console.log(chalk_1.default.gray(` 4. Add validation in DTOs and validation files`));
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
console.log(chalk_1.default.gray(` 2. Add schema fields in: models/${kebab}.model.ts`));
|
|
211
|
+
console.log(chalk_1.default.gray(` 3. Implement repository methods in: repositories/${kebab}.repository.ts`));
|
|
212
|
+
console.log(chalk_1.default.gray(` 4. Add service methods in: services/${kebab}.service.ts`));
|
|
213
|
+
}
|
|
214
|
+
console.log(chalk_1.default.gray(`\n Feature location: ${featureDir}`));
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,sCAyLC;AA3MD,2CAA6B;AAC7B,kDAA0B;AAC1B,oDAO6B;AAC7B,oEAAyE;AACzE,sDAAoD;AAOpD,SAAgB,aAAa,CACzB,WAAmB,EACnB,UAAkB,IAAI,EACtB,UAAmB,KAAK;IAExB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAElD,0CAA0C;IAC1C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,wBAAW,EAAC,WAAW,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,KAAK,CAAC,CAAC;IAExC,kCAAkC;IAClC,IAAI,IAAA,uBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,YAAY,KAAK,mBAAmB,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEjE,MAAM,GAAG,G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,KAAK,aAAa,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,yBAAyB,UAAU,EAAE,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CA8BvD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteFeature = deleteFeature;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const file_utils_1 = require("../utils/file-utils");
|
|
9
|
+
const route_utils_1 = require("../utils/route-utils");
|
|
10
|
+
function deleteFeature(featureName) {
|
|
11
|
+
console.log(chalk_1.default.blue('šļø Deleting feature...'));
|
|
12
|
+
// Convert feature name to kebab case
|
|
13
|
+
const { kebab } = (0, file_utils_1.convertCase)(featureName);
|
|
14
|
+
const featureDir = (0, file_utils_1.getFeatureDir)(kebab);
|
|
15
|
+
// Check if feature exists
|
|
16
|
+
if (!(0, file_utils_1.fileExists)(featureDir)) {
|
|
17
|
+
throw new Error(`Feature '${kebab}' does not exist!`);
|
|
18
|
+
}
|
|
19
|
+
console.log(chalk_1.default.gray(`Feature: ${kebab}`));
|
|
20
|
+
// Remove feature directory
|
|
21
|
+
console.log(chalk_1.default.blue('\nš Removing directory...'));
|
|
22
|
+
(0, file_utils_1.removeDir)(featureDir);
|
|
23
|
+
console.log(chalk_1.default.green(` ā Removed: ${featureDir}`));
|
|
24
|
+
// Clean up routes
|
|
25
|
+
console.log(chalk_1.default.blue('\nš Cleaning up routes...'));
|
|
26
|
+
try {
|
|
27
|
+
(0, route_utils_1.cleanupRoutes)(kebab);
|
|
28
|
+
console.log(chalk_1.default.green(' ā Routes cleaned up'));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.log(chalk_1.default.yellow(' ā Could not clean up routes (may need to be done manually)'));
|
|
32
|
+
}
|
|
33
|
+
// Success message
|
|
34
|
+
console.log(chalk_1.default.green.bold(`\n⨠Feature '${kebab}' deleted successfully!`));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=delete.js.map
|