11import { Listr , ListrTask } from 'listr2' ;
22import clear from 'clear' ;
33import { yellow } from 'chalk' ;
4- import { PromisifiedFs } from 'codestore-utils' ;
4+ import {
5+ PromisifiedFs , compile , PathsResolverTool , GraphqlValidatorTool ,
6+ } from 'codestore-utils' ;
57import { Connection } from 'typeorm' ;
68import Command from '../../lib/command' ;
79import Aliases from '../../common/constants/aliases' ;
810import FileWorker from '../../common/file-worker' ;
9- import Paths from '../../common/constants/paths' ;
10- import compile from '../../lib/compiler' ;
1111import { installDependencies } from '../../lib/child-cli' ;
1212import { generateChecksumForFile } from '../../common/utils' ;
1313
@@ -16,7 +16,7 @@ const firstLine = (str: string): string => str.split('\n')[0].replace(/:$/, '').
1616export const migrationsAreActual = async ( context : Command ) : Promise < boolean > => {
1717 const checksum = await generateChecksumForFile ( context . serviceWorker . schemaPath ) ;
1818
19- const migrations = await PromisifiedFs . readdir ( Paths . MIGRATIONS ) ;
19+ const migrations = await PromisifiedFs . readdir ( PathsResolverTool . MIGRATIONS ) ;
2020 const lastMigration = migrations . pop ( ) ;
2121 const lastMigrationChecksum = lastMigration ?. split ( '_' ) ?. [ 1 ] ?. replace ( / \. t s / g, '' ) ;
2222
@@ -28,23 +28,23 @@ export const generateFlow = (context: Command, error: (input: string | Error, op
2828 title : 'Compiling your code' ,
2929 task : async ( ) : Promise < void > => {
3030 await installDependencies ( ) ;
31- await compile ( await context . serviceWorker . loadResolversPaths ( ) ) ;
31+ await compile ( await PathsResolverTool . loadFilesToCompile ( ) ) ;
3232 } ,
3333 } ,
3434 {
3535 title : 'Validating schema' ,
3636 task : async ( ) : Promise < void > => {
37- await context . serviceWorker . validateSchema ( ) ;
37+ await GraphqlValidatorTool . validateSchema ( ) ;
3838 if ( context . id !== 'service:generate' ) {
39- await context . serviceWorker . validateQueriesAndMutations ( ) ;
39+ await GraphqlValidatorTool . validateQueriesAndMutations ( ) ;
4040 }
4141 } ,
4242 } ,
4343 {
4444 title : 'Preparing the service code for upload' ,
4545 task : async ( ctx ) : Promise < void > => {
46- await PromisifiedFs . createFolderIfNotExist ( Paths . MIGRATIONS ) ;
47- await PromisifiedFs . createFolderIfNotExist ( Paths . ENTITIES ) ;
46+ await PromisifiedFs . createFolderIfNotExist ( PathsResolverTool . MIGRATIONS ) ;
47+ await PromisifiedFs . createFolderIfNotExist ( PathsResolverTool . ENTITIES ) ;
4848 ctx . encodedZip = await FileWorker . zipFolder ( ) ;
4949 } ,
5050 } ,
@@ -66,7 +66,7 @@ export const generateFlow = (context: Command, error: (input: string | Error, op
6666 return ;
6767 }
6868
69- const currentMigrations = ( await PromisifiedFs . readdir ( Paths . MIGRATIONS ) )
69+ const currentMigrations = ( await PromisifiedFs . readdir ( PathsResolverTool . MIGRATIONS ) )
7070 . filter ( ( name ) => / \. t s $ / . test ( name ) ) ;
7171
7272 // eslint-disable-next-line no-param-reassign
@@ -121,12 +121,12 @@ export const generateFlow = (context: Command, error: (input: string | Error, op
121121 error ( 'An error occured' , { exit : 1 } ) ;
122122 }
123123
124- await PromisifiedFs . rimraf ( Paths . MIGRATIONS ) ;
125- await PromisifiedFs . rimraf ( Paths . ENTITIES ) ;
126- await PromisifiedFs . rimraf ( Paths . DIST ) ;
127- await PromisifiedFs . rimraf ( Paths . BUILD ) ;
128- await FileWorker . saveZipFromB64 ( generated , Paths . DATA ) ;
129- await compile ( await context . serviceWorker . loadResolversPaths ( ) ) ;
124+ await PromisifiedFs . rimraf ( PathsResolverTool . MIGRATIONS ) ;
125+ await PromisifiedFs . rimraf ( PathsResolverTool . ENTITIES ) ;
126+ await PromisifiedFs . rimraf ( PathsResolverTool . DIST ) ;
127+ await PromisifiedFs . rimraf ( PathsResolverTool . BUILD ) ;
128+ await FileWorker . saveZipFromB64 ( generated , PathsResolverTool . DATA ) ;
129+ await compile ( await PathsResolverTool . loadFilesToCompile ( ) ) ;
130130
131131 // eslint-disable-next-line no-param-reassign
132132 task . title = 'Generated code has been saved' ;
0 commit comments