@nest-extended/cli 0.0.2-beta-14 → 0.0.2-beta-15
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 +73 -9
- package/package.json +1 -1
- package/src/commands/generate-app.js +145 -30
- package/src/commands/generate-app.js.map +1 -1
- package/src/commands/generate-service.js +204 -15
- package/src/commands/generate-service.js.map +1 -1
- package/src/lib/generate-prisma-auth-services.d.ts +1 -0
- package/src/lib/generate-prisma-auth-services.js +38 -0
- package/src/lib/generate-prisma-auth-services.js.map +1 -0
- package/src/templates/dto-class-validator.template.d.ts +1 -0
- package/src/templates/dto-class-validator.template.js +93 -0
- package/src/templates/dto-class-validator.template.js.map +1 -0
- package/src/templates/dto.template.js +19 -0
- package/src/templates/dto.template.js.map +1 -1
- package/src/templates/prisma-auth.template.d.ts +9 -0
- package/src/templates/prisma-auth.template.js +190 -0
- package/src/templates/prisma-auth.template.js.map +1 -0
- package/src/templates/prisma-controller.template.d.ts +1 -0
- package/src/templates/prisma-controller.template.js +53 -0
- package/src/templates/prisma-controller.template.js.map +1 -0
- package/src/templates/prisma-dto-class-validator.template.d.ts +1 -0
- package/src/templates/prisma-dto-class-validator.template.js +93 -0
- package/src/templates/prisma-dto-class-validator.template.js.map +1 -0
- package/src/templates/prisma-dto.template.d.ts +1 -0
- package/src/templates/prisma-dto.template.js +55 -0
- package/src/templates/prisma-dto.template.js.map +1 -0
- package/src/templates/prisma-model.template.d.ts +7 -0
- package/src/templates/prisma-model.template.js +27 -0
- package/src/templates/prisma-model.template.js.map +1 -0
- package/src/templates/prisma-module.template.d.ts +1 -0
- package/src/templates/prisma-module.template.js +18 -0
- package/src/templates/prisma-module.template.js.map +1 -0
- package/src/templates/prisma-service.template.d.ts +1 -0
- package/src/templates/prisma-service.template.js +15 -0
- package/src/templates/prisma-service.template.js.map +1 -0
- package/src/templates/prisma-setup.template.d.ts +6 -0
- package/src/templates/prisma-setup.template.js +34 -0
- package/src/templates/prisma-setup.template.js.map +1 -0
- package/src/templates/prisma-users.template.d.ts +8 -0
- package/src/templates/prisma-users.template.js +135 -0
- package/src/templates/prisma-users.template.js.map +1 -0
- package/src/templates/schema.template.js +8 -4
- package/src/templates/schema.template.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @nest-extended/cli
|
|
2
2
|
|
|
3
|
-
A powerful command-line interface for the **NestExtended** ecosystem. This CLI automates the creation of modules, services, controllers, schemas, and DTOs, ensuring your project follows best practices and maintains consistency.
|
|
3
|
+
A powerful command-line interface for the **NestExtended** ecosystem. This CLI automates the creation of modules, services, controllers, schemas, and DTOs, ensuring your project follows best practices and maintains consistency. It also provides migration tools for upgrading between versions.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -25,15 +25,19 @@ yarn add -D @nest-extended/cli
|
|
|
25
25
|
### Generate Application (`g app`)
|
|
26
26
|
|
|
27
27
|
Generates a fully configured NestJS application with standard best-practices built right in.
|
|
28
|
-
It interactively prompts for your choice of database (currently supporting MongoDB) and handles scaffolding the app. It also prompts whether you want to automatically generate authentication modules.
|
|
28
|
+
It interactively prompts for your choice of database (currently supporting MongoDB), package manager (npm/yarn/pnpm), and handles scaffolding the app. It also prompts whether you want to automatically generate authentication modules.
|
|
29
29
|
|
|
30
30
|
**Includes:**
|
|
31
31
|
- Running `@nestjs/cli`'s `nest new` command internally
|
|
32
32
|
- `Mongoose` schema integration out of the box
|
|
33
33
|
- Context-mapping out of the box using `nestjs-cls`
|
|
34
34
|
- Built-in `AuthModule` with JSON Web Token (JWT) handling via `@nestjs/jwt` and password hashing with `bcrypt` (opt-in)
|
|
35
|
-
- Fully functional `UsersModule` equipped with standard fields and authentication logic implementations
|
|
35
|
+
- Fully functional `UsersModule` equipped with standard fields and authentication logic implementations (opt-in)
|
|
36
36
|
- Pre-configured `NestExtendedModule` context for soft deletes functionality
|
|
37
|
+
- `GlobalExceptionFilter` and `NullResponseInterceptor` auto-registered as global providers
|
|
38
|
+
- `@nestjs/config` with `.env` file support
|
|
39
|
+
- Zod validation library pre-installed
|
|
40
|
+
- Auto-linting after generation
|
|
37
41
|
|
|
38
42
|
**Usage:**
|
|
39
43
|
|
|
@@ -53,6 +57,18 @@ nest-cli g app e-commerce-dashboard
|
|
|
53
57
|
|
|
54
58
|
If you generated a NestJS application without the authentication modules and want to add them later, use the `auth` command. This will scaffold out the `Auth` and `Users` modules, install `@nestjs/jwt` and `bcrypt`, and hook them into your `app.module.ts`.
|
|
55
59
|
|
|
60
|
+
**What it generates:**
|
|
61
|
+
- `src/services/auth/auth.module.ts` — Auth module with JWT configuration and global guard
|
|
62
|
+
- `src/services/auth/auth.service.ts` — Service with `signInLocal()` (email/password, bcrypt)
|
|
63
|
+
- `src/services/auth/auth.controller.ts` — `/authentication` endpoint with sign-in and verify routes
|
|
64
|
+
- `src/services/auth/auth.guard.ts` — JWT auth guard with CLS user injection
|
|
65
|
+
- `src/services/auth/constants/jwt-constants.ts` — JWT secret from env or random fallback
|
|
66
|
+
- `src/services/users/users.module.ts` — Users module
|
|
67
|
+
- `src/services/users/users.service.ts` — NestService extension with `sanitizeUser()`
|
|
68
|
+
- `src/services/users/users.controller.ts` — CRUD + password hashing + block endpoint
|
|
69
|
+
- `src/schemas/users.schema.ts` — User schema (firstName, lastName, email, password, phone, role)
|
|
70
|
+
- `src/services/users/dto/users.dto.ts` — Zod validation schemas
|
|
71
|
+
|
|
56
72
|
**Usage:**
|
|
57
73
|
|
|
58
74
|
```bash
|
|
@@ -64,15 +80,17 @@ nest-cli generate auth
|
|
|
64
80
|
### Generate Service (`g service`)
|
|
65
81
|
|
|
66
82
|
Generates a complete resource bundle including:
|
|
67
|
-
- **Module**: Registers the controller and service.
|
|
68
|
-
- **Service**: Extends `NestService` from `@nest-extended/mongoose
|
|
69
|
-
- **Controller**:
|
|
70
|
-
- **Schema**: Mongoose schema with `timestamps` and soft delete fields (only injects `createdBy`, `updatedBy`, `deletedBy` mapping if Auth was generated)
|
|
71
|
-
- **DTO**: Data Transfer Object with validation
|
|
72
|
-
- **Specs**: Unit tests for service and controller
|
|
83
|
+
- **Module**: Registers the controller and service, imports MongooseModule.forFeature
|
|
84
|
+
- **Service**: Extends `NestService` from `@nest-extended/mongoose`
|
|
85
|
+
- **Controller**: Custom controller with full CRUD (find, get, create, patch, delete) using `@ModifyBody(setCreatedBy())` and `@User()` decorators
|
|
86
|
+
- **Schema**: Mongoose schema with `timestamps` and soft delete fields (only injects `createdBy`, `updatedBy`, `deletedBy` mapping if Auth was generated)
|
|
87
|
+
- **DTO**: Data Transfer Object with Zod validation (Create, Patch, Remove schemas + inferred types)
|
|
88
|
+
- **Specs**: Unit tests for service and controller
|
|
73
89
|
|
|
74
90
|
It also automatically updates your `src/app.module.ts` to include the new module.
|
|
75
91
|
|
|
92
|
+
**Supports nested paths** — use `/` to create nested service directories (e.g., `nest-cli g service qna/category`).
|
|
93
|
+
|
|
76
94
|
**Usage:**
|
|
77
95
|
|
|
78
96
|
```bash
|
|
@@ -95,3 +113,49 @@ This will create:
|
|
|
95
113
|
- `src/schemas/userProfile.schema.ts`
|
|
96
114
|
- `src/services/userProfile/userProfile.service.spec.ts`
|
|
97
115
|
- `src/services/userProfile/userProfile.controller.spec.ts`
|
|
116
|
+
|
|
117
|
+
Nested example:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
nest-cli g service qna/category
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This will create files under `src/services/qna/category/` and `src/schemas/qna/category.schema.ts`.
|
|
124
|
+
|
|
125
|
+
### Migration (`m run`)
|
|
126
|
+
|
|
127
|
+
Runs migration scripts to update the codebase for newer versions. Currently handles:
|
|
128
|
+
- Moving decorator imports (`ModifyBody`, `User`, `Public`, `setCreatedBy`) from `@nest-extended/core` to `@nest-extended/decorators`
|
|
129
|
+
|
|
130
|
+
**Usage:**
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
nest-cli m run
|
|
134
|
+
# or
|
|
135
|
+
nest-cli migration run
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Version
|
|
139
|
+
|
|
140
|
+
Output the current CLI version:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
nest-cli version
|
|
144
|
+
# or
|
|
145
|
+
nest-cli v
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Help
|
|
149
|
+
|
|
150
|
+
Display comprehensive help for all commands:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
nest-cli help
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Naming Convention
|
|
157
|
+
|
|
158
|
+
The CLI automatically handles name transformation:
|
|
159
|
+
- Accepts kebab-case input: `user-profile`
|
|
160
|
+
- Converts to PascalCase for classes: `UserProfile`
|
|
161
|
+
- Converts to camelCase for files and variables: `userProfile`
|
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@ const path = require("path");
|
|
|
8
8
|
const fs = require("fs-extra");
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const generate_auth_services_1 = require("../lib/generate-auth-services");
|
|
11
|
+
const generate_prisma_auth_services_1 = require("../lib/generate-prisma-auth-services");
|
|
12
|
+
const prisma_setup_template_1 = require("../templates/prisma-setup.template");
|
|
11
13
|
const generateAppAction = (appName) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
14
|
const questions = [
|
|
13
15
|
{
|
|
@@ -21,7 +23,15 @@ const generateAppAction = (appName) => tslib_1.__awaiter(void 0, void 0, void 0,
|
|
|
21
23
|
type: 'list',
|
|
22
24
|
name: 'database',
|
|
23
25
|
message: 'Which database would you like to use?',
|
|
24
|
-
choices: ['
|
|
26
|
+
choices: ['Mongoose', 'PostgreSQL', 'MySQL', 'SQLite'],
|
|
27
|
+
default: 'Mongoose',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'list',
|
|
31
|
+
name: 'validatorType',
|
|
32
|
+
message: 'Which validation library would you like to use?',
|
|
33
|
+
choices: ['zod', 'class-validator'],
|
|
34
|
+
default: 'zod',
|
|
25
35
|
},
|
|
26
36
|
{
|
|
27
37
|
type: 'confirm',
|
|
@@ -35,12 +45,10 @@ const generateAppAction = (appName) => tslib_1.__awaiter(void 0, void 0, void 0,
|
|
|
35
45
|
const answers = yield inquirer.prompt(questions);
|
|
36
46
|
const database = answers['database'];
|
|
37
47
|
const pkgManager = answers['pkgManager'];
|
|
48
|
+
const validatorType = answers['validatorType'];
|
|
38
49
|
const generateAuth = answers['generateAuth'];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
console.log(chalk.blue(`Generating NestJS app: ${appName}`));
|
|
50
|
+
const isPrisma = database !== 'Mongoose';
|
|
51
|
+
console.log(chalk.blue(`Generating NestJS app: ${appName} with ${database}`));
|
|
44
52
|
const appDir = path.join(process.cwd(), appName);
|
|
45
53
|
// 1. Run nest new
|
|
46
54
|
yield new Promise((resolve, reject) => {
|
|
@@ -62,15 +70,23 @@ const generateAppAction = (appName) => tslib_1.__awaiter(void 0, void 0, void 0,
|
|
|
62
70
|
yield new Promise((resolve, reject) => {
|
|
63
71
|
const installArgs = pkgManager === 'npm' ? ['install'] : ['add'];
|
|
64
72
|
const baseDeps = [
|
|
65
|
-
'@nestjs/mongoose',
|
|
66
|
-
'mongoose',
|
|
67
73
|
'@nestjs/config',
|
|
68
74
|
'nestjs-cls',
|
|
69
75
|
`@nest-extended/core@${nestExtendedVersion}`,
|
|
70
|
-
`@nest-extended/mongoose@${nestExtendedVersion}`,
|
|
71
76
|
`@nest-extended/decorators@${nestExtendedVersion}`,
|
|
72
|
-
'zod'
|
|
73
77
|
];
|
|
78
|
+
if (isPrisma) {
|
|
79
|
+
baseDeps.push('@prisma/client', `@nest-extended/prisma@${nestExtendedVersion}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
baseDeps.push('@nestjs/mongoose', 'mongoose', `@nest-extended/mongoose@${nestExtendedVersion}`);
|
|
83
|
+
}
|
|
84
|
+
if (validatorType === 'zod') {
|
|
85
|
+
baseDeps.push('zod');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
baseDeps.push('class-validator', 'class-transformer');
|
|
89
|
+
}
|
|
74
90
|
if (generateAuth) {
|
|
75
91
|
baseDeps.push('@nestjs/jwt', 'bcrypt');
|
|
76
92
|
}
|
|
@@ -90,10 +106,15 @@ const generateAppAction = (appName) => tslib_1.__awaiter(void 0, void 0, void 0,
|
|
|
90
106
|
});
|
|
91
107
|
});
|
|
92
108
|
// 3. Install Dev dependencies
|
|
93
|
-
|
|
109
|
+
const devDeps = [];
|
|
110
|
+
if (generateAuth)
|
|
111
|
+
devDeps.push('@types/bcrypt');
|
|
112
|
+
if (isPrisma)
|
|
113
|
+
devDeps.push('prisma');
|
|
114
|
+
if (devDeps.length > 0) {
|
|
94
115
|
yield new Promise((resolve, reject) => {
|
|
95
116
|
const devArgs = pkgManager === 'npm' ? ['install', '-D'] : ['add', '-D'];
|
|
96
|
-
const child = (0, child_process_1.spawn)(pkgManager, [...devArgs,
|
|
117
|
+
const child = (0, child_process_1.spawn)(pkgManager, [...devArgs, ...devDeps], {
|
|
97
118
|
stdio: 'inherit',
|
|
98
119
|
cwd: appDir,
|
|
99
120
|
shell: true,
|
|
@@ -107,13 +128,107 @@ const generateAppAction = (appName) => tslib_1.__awaiter(void 0, void 0, void 0,
|
|
|
107
128
|
});
|
|
108
129
|
}
|
|
109
130
|
console.log(chalk.blue('Configuring project...'));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
if (isPrisma) {
|
|
132
|
+
// --- Prisma-based app setup ---
|
|
133
|
+
// Initialize Prisma
|
|
134
|
+
let datasourceProvider = 'postgresql';
|
|
135
|
+
if (database === 'MySQL')
|
|
136
|
+
datasourceProvider = 'mysql';
|
|
137
|
+
else if (database === 'SQLite')
|
|
138
|
+
datasourceProvider = 'sqlite';
|
|
139
|
+
yield new Promise((resolve, reject) => {
|
|
140
|
+
const child = (0, child_process_1.spawn)('npx', ['prisma', 'init', '--datasource-provider', datasourceProvider], {
|
|
141
|
+
stdio: 'inherit',
|
|
142
|
+
cwd: appDir,
|
|
143
|
+
shell: true,
|
|
144
|
+
});
|
|
145
|
+
child.on('close', (code) => {
|
|
146
|
+
if (code === 0)
|
|
147
|
+
resolve();
|
|
148
|
+
else
|
|
149
|
+
reject(new Error(`prisma init failed with code ${code}`));
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
// Create PrismaService and PrismaModule
|
|
153
|
+
const prismaDir = path.join(appDir, 'src/prisma');
|
|
154
|
+
fs.ensureDirSync(prismaDir);
|
|
155
|
+
fs.writeFileSync(path.join(prismaDir, 'prisma.service.ts'), (0, prisma_setup_template_1.getPrismaServiceFile)());
|
|
156
|
+
fs.writeFileSync(path.join(prismaDir, 'prisma.module.ts'), (0, prisma_setup_template_1.getPrismaModuleFile)());
|
|
157
|
+
// Update app.module.ts for Prisma
|
|
158
|
+
const appModulePath = path.join(appDir, 'src/app.module.ts');
|
|
159
|
+
let appModuleContent = fs.readFileSync(appModulePath, 'utf8');
|
|
160
|
+
const authImports = generateAuth ? `
|
|
161
|
+
import { AuthModule } from './services/auth/auth.module';
|
|
162
|
+
import { UsersModule } from './services/users/users.module';` : '';
|
|
163
|
+
const importsToAdd = `
|
|
164
|
+
import { APP_FILTER, APP_INTERCEPTOR } from '@nestjs/core';
|
|
165
|
+
import { GlobalExceptionFilter } from '@nest-extended/prisma';
|
|
166
|
+
import { ConfigModule } from '@nestjs/config';
|
|
167
|
+
import { ClsModule } from 'nestjs-cls';
|
|
168
|
+
import { NestExtendedModule, NullResponseInterceptor } from '@nest-extended/core';
|
|
169
|
+
import { PrismaModule } from './prisma/prisma.module';${authImports}
|
|
170
|
+
`;
|
|
171
|
+
appModuleContent = importsToAdd + appModuleContent;
|
|
172
|
+
const deletedByProp = generateAuth ? `
|
|
173
|
+
deletedBy: user?.id,` : '';
|
|
174
|
+
const authModuleImports = generateAuth ? `
|
|
175
|
+
AuthModule,
|
|
176
|
+
UsersModule,` : '';
|
|
177
|
+
const nestImports = `
|
|
178
|
+
ConfigModule.forRoot({
|
|
179
|
+
envFilePath: ['.env'],
|
|
180
|
+
isGlobal: true,
|
|
181
|
+
}),
|
|
182
|
+
ClsModule.forRoot({
|
|
183
|
+
global: true,
|
|
184
|
+
middleware: { mount: true },
|
|
185
|
+
}),
|
|
186
|
+
NestExtendedModule.forRoot({
|
|
187
|
+
softDelete: {
|
|
188
|
+
getQuery: () => ({ deleted: { not: true } }),
|
|
189
|
+
getData: (user: { id?: string } | null) => ({
|
|
190
|
+
deleted: true,${deletedByProp}
|
|
191
|
+
deletedAt: new Date(),
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
194
|
+
}),
|
|
195
|
+
PrismaModule,${authModuleImports}`;
|
|
196
|
+
appModuleContent = appModuleContent.replace(/imports:\s*\[/, `imports: [\n${nestImports}`);
|
|
197
|
+
const appProviders = `providers: [
|
|
198
|
+
AppService,
|
|
199
|
+
{
|
|
200
|
+
provide: APP_FILTER,
|
|
201
|
+
useClass: GlobalExceptionFilter,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
provide: APP_INTERCEPTOR,
|
|
205
|
+
useClass: NullResponseInterceptor,
|
|
206
|
+
},
|
|
207
|
+
],`;
|
|
208
|
+
appModuleContent = appModuleContent.replace(/providers:\s*\[AppService\],?/, appProviders);
|
|
209
|
+
fs.writeFileSync(appModulePath, appModuleContent);
|
|
210
|
+
// Write .env file
|
|
211
|
+
let databaseUrl = 'postgresql://user:password@localhost:5432/mydb?schema=public';
|
|
212
|
+
if (database === 'MySQL')
|
|
213
|
+
databaseUrl = 'mysql://user:password@localhost:3306/mydb';
|
|
214
|
+
else if (database === 'SQLite')
|
|
215
|
+
databaseUrl = 'file:./dev.db';
|
|
216
|
+
fs.writeFileSync(path.join(appDir, '.env'), `DATABASE_URL="${databaseUrl}"
|
|
217
|
+
JWT_SECRET=super-secret-jwt-key
|
|
218
|
+
`);
|
|
219
|
+
if (generateAuth) {
|
|
220
|
+
(0, generate_prisma_auth_services_1.generatePrismaAuthServices)(appDir);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
// --- Mongoose-based app setup (existing behavior) ---
|
|
225
|
+
// 4. Update app.module.ts
|
|
226
|
+
const appModulePath = path.join(appDir, 'src/app.module.ts');
|
|
227
|
+
let appModuleContent = fs.readFileSync(appModulePath, 'utf8');
|
|
228
|
+
const authImports = generateAuth ? `
|
|
114
229
|
import { AuthModule } from './services/auth/auth.module';
|
|
115
230
|
import { UsersModule } from './services/users/users.module';` : '';
|
|
116
|
-
|
|
231
|
+
const importsToAdd = `
|
|
117
232
|
import { APP_FILTER, APP_INTERCEPTOR } from '@nestjs/core';
|
|
118
233
|
import { GlobalExceptionFilter } from '@nest-extended/mongoose';
|
|
119
234
|
import { ConfigModule } from '@nestjs/config';
|
|
@@ -121,13 +236,13 @@ import { ClsModule } from 'nestjs-cls';
|
|
|
121
236
|
import { NestExtendedModule, NullResponseInterceptor } from '@nest-extended/core';
|
|
122
237
|
import { MongooseModule } from '@nestjs/mongoose';${authImports}
|
|
123
238
|
`;
|
|
124
|
-
|
|
125
|
-
|
|
239
|
+
appModuleContent = importsToAdd + appModuleContent;
|
|
240
|
+
const deletedByProp = generateAuth ? `
|
|
126
241
|
deletedBy: user?._id,` : '';
|
|
127
|
-
|
|
242
|
+
const authModuleImports = generateAuth ? `
|
|
128
243
|
AuthModule,
|
|
129
244
|
UsersModule,` : '';
|
|
130
|
-
|
|
245
|
+
const nestImports = `
|
|
131
246
|
ConfigModule.forRoot({
|
|
132
247
|
envFilePath: ['.env'],
|
|
133
248
|
isGlobal: true,
|
|
@@ -146,9 +261,8 @@ import { MongooseModule } from '@nestjs/mongoose';${authImports}
|
|
|
146
261
|
},
|
|
147
262
|
}),
|
|
148
263
|
MongooseModule.forRoot(process.env.MONGODB_URI || 'mongodb://localhost:27017/test'),${authModuleImports}`;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const appProviders = `providers: [
|
|
264
|
+
appModuleContent = appModuleContent.replace(/imports:\s*\[/, `imports: [\n${nestImports}`);
|
|
265
|
+
const appProviders = `providers: [
|
|
152
266
|
AppService,
|
|
153
267
|
{
|
|
154
268
|
provide: APP_FILTER,
|
|
@@ -159,14 +273,15 @@ ${nestImports}`);
|
|
|
159
273
|
useClass: NullResponseInterceptor,
|
|
160
274
|
},
|
|
161
275
|
],`;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
276
|
+
appModuleContent = appModuleContent.replace(/providers:\s*\[AppService\],?/, appProviders);
|
|
277
|
+
fs.writeFileSync(appModulePath, appModuleContent);
|
|
278
|
+
// Write .env file
|
|
279
|
+
fs.writeFileSync(path.join(appDir, '.env'), `MONGODB_URI=mongodb://localhost:27017/test
|
|
166
280
|
JWT_SECRET=super-secret-jwt-key
|
|
167
281
|
`);
|
|
168
|
-
|
|
169
|
-
|
|
282
|
+
if (generateAuth) {
|
|
283
|
+
(0, generate_auth_services_1.generateAuthServices)(appDir);
|
|
284
|
+
}
|
|
170
285
|
}
|
|
171
286
|
console.log(chalk.blue('Running lint...'));
|
|
172
287
|
yield new Promise((resolve) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-app.js","sourceRoot":"","sources":["../../../../../packages/cli/src/commands/generate-app.ts"],"names":[],"mappings":";;;;AAAA,qCAAqC;AACrC,+BAA+B;AAC/B,6BAA6B;AAC7B,+BAA+B;AAC/B,iDAAsC;AAItC,0EAAqE;
|
|
1
|
+
{"version":3,"file":"generate-app.js","sourceRoot":"","sources":["../../../../../packages/cli/src/commands/generate-app.ts"],"names":[],"mappings":";;;;AAAA,qCAAqC;AACrC,+BAA+B;AAC/B,6BAA6B;AAC7B,+BAA+B;AAC/B,iDAAsC;AAItC,0EAAqE;AACrE,wFAAkF;AAClF,8E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