1+ import { FsUtilities } from '../../encapsulation' ;
2+ import { adminControllerContent } from '../../loopback/admin-controller.content' ;
3+ import { adminModelContent } from '../../loopback/admin-model.content' ;
4+ import { fullAdminModelContent } from '../../loopback/full-admin-model.content' ;
5+ import { newAdminModelContent } from '../../loopback/new-admin-model.content' ;
6+ import { Path , getPath } from '../../utilities' ;
7+
8+ // eslint-disable-next-line jsdoc/require-jsdoc
9+ export async function createAdminFilesMock ( root : string , dbName : string ) : Promise < void > {
10+ const adminModelTs : Path = getPath ( root , 'src' , 'models' , 'admin.model.ts' ) ;
11+ await FsUtilities . createFile ( adminModelTs , adminModelContent ) ;
12+ await FsUtilities . createFile (
13+ getPath ( root , 'src' , 'models' , 'roles.enum.ts' ) ,
14+ [
15+ 'export enum Roles {' ,
16+ '\tADMIN = \'ADMIN\'' ,
17+ '}'
18+ ]
19+ ) ;
20+ await FsUtilities . createFile (
21+ getPath ( root , 'src' , 'models' , 'index.ts' ) ,
22+ [
23+ 'export * from \'./admin.model\';' ,
24+ 'export * from \'./roles.enum\';'
25+ ]
26+ ) ;
27+
28+ const adminRepositoryTs : Path = getPath ( root , 'src' , 'repositories' , 'admin.repository.ts' ) ;
29+ await FsUtilities . createFile ( adminRepositoryTs , [ ] ) ;
30+
31+ const controllerPath : string = getPath ( root , 'src' , 'controllers' ) ;
32+ await FsUtilities . createFile ( getPath ( controllerPath , 'admin' , 'admin.controller.ts' ) , adminControllerContent ( dbName ) ) ;
33+ await FsUtilities . updateFile ( getPath ( controllerPath , 'index.ts' ) , 'export * from \'./admin/admin.controller\';' , 'append' ) ;
34+
35+ await FsUtilities . createFile ( getPath ( controllerPath , 'admin' , 'new-admin.model.ts' ) , newAdminModelContent ) ;
36+ await FsUtilities . createFile ( getPath ( controllerPath , 'admin' , 'full-admin.model.ts' ) , fullAdminModelContent ) ;
37+ }
0 commit comments