Skip to content

Commit 18f835a

Browse files
Merge branch 'auto-create-monorepo-name-convention' of https://github.com/SSCIsrael/schematics into SSCIsrael-auto-create-monorepo-name-convention
2 parents 230152e + 9771379 commit 18f835a

13 files changed

+61
-62
lines changed

src/lib/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const DEFAULT_VERSION = '0.0.1';
55
export const DEFAULT_PATH_NAME = 'src';
66
export const DEFAULT_LIB_PATH = 'libs';
77
export const DEFAULT_APPS_PATH = 'apps';
8+
export const DEFAULT_APP_NAME = 'app';
89
export const DEFAULT_DIR_ENTRY_APP = 'main';
910
export const TEST_ENV = 'test';
1011
export const PROJECT_TYPE = {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Test, TestingModule } from '@nestjs/testing';
2+
import { <%= classify(name) %>Controller } from './<%= name %>.controller';
3+
import { <%= classify(name) %>Service } from './<%= name %>.service';
4+
5+
describe('AppController', () => {
6+
let <%= camelize(name) %>Controller: <%= classify(name) %>Controller;
7+
8+
beforeEach(async () => {
9+
const app: TestingModule = await Test.createTestingModule({
10+
controllers: [<%= classify(name) %>Controller],
11+
providers: [<%= classify(name) %>Service],
12+
}).compile();
13+
14+
<%= camelize(name) %>Controller = app.get<<%= classify(name) %>Controller>(<%= classify(name) %>Controller);
15+
});
16+
17+
describe('root', () => {
18+
it('should return "Hello World!"', () => {
19+
expect(<%= camelize(name) %>Controller.getHello()).toBe('Hello World!');
20+
});
21+
});
22+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Controller, Get } from '@nestjs/common';
2+
import { <%= classify(name) %>Service } from './<%= name %>.service';
3+
4+
@Controller()
5+
export class <%= classify(name) %>Controller {
6+
constructor(private readonly <%= camelize(name) %>Service: <%= classify(name) %>Service) {}
7+
8+
@Get()
9+
getHello(): string {
10+
return this.<%= camelize(name) %>Service.getHello();
11+
}
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Module } from '@nestjs/common';
2+
import { <%= classify(name) %>Controller } from './<%= name %>.controller';
3+
import { <%= classify(name) %>Service } from './<%= name %>.service';
4+
5+
@Module({
6+
imports: [],
7+
controllers: [<%= classify(name) %>Controller],
8+
providers: [<%= classify(name) %>Service],
9+
})
10+
export class <%= classify(name) %>Module {}

src/lib/sub-app/files/ts/src/app.service.ts renamed to src/lib/sub-app/files/ts/src/__name__.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@nestjs/common';
22

33
@Injectable()
4-
export class AppService {
4+
export class <%= classify(name)%>Service {
55
getHello(): string {
66
return 'Hello World!';
77
}

src/lib/sub-app/files/ts/src/app.controller.spec.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/lib/sub-app/files/ts/src/app.controller.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/lib/sub-app/files/ts/src/app.module.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/lib/sub-app/files/ts/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NestFactory } from '@nestjs/core';
2-
import { AppModule } from './app.module';
2+
import { <%= classify(name) %>Module } from './<%= name %>.module';
33

44
async function bootstrap() {
5-
const app = await NestFactory.create(AppModule);
5+
const app = await NestFactory.create(<%= classify(name) %>Module);
66
await app.listen(3000);
77
}
88
bootstrap();

src/lib/sub-app/files/ts/test/app.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Test, TestingModule } from '@nestjs/testing';
22
import * as request from 'supertest';
3-
import { AppModule } from './../src/app.module';
3+
import { <%= classify(name)%>Module } from './../src/<%= classify(name)%>.module';
44

55
describe('AppController (e2e)', () => {
66
let app;
77

88
beforeEach(async () => {
99
const moduleFixture: TestingModule = await Test.createTestingModule({
10-
imports: [AppModule],
10+
imports: [<%= classify(name)%>Module],
1111
}).compile();
1212

1313
app = moduleFixture.createNestApplication();

0 commit comments

Comments
 (0)