import fse from 'fs-extra' ; import path from 'path' ; import { JsPackageManager } from '../js-package-manager/JsPackageManager' ; import { InitiateOptions } from '../initiate' ; function installDependencies ( packageManager ) { const packageJson = packageManager . retrievePackageJson ( ) ; const dependencies = [ '@ezbackend/core' , '@ezbackend/common' , '@ezbackend/cors' , '@ezbackend/utils' , ] ; packageManager . addDependencies ( { packageJson : packageJson , installAsDevDependencies : false , } , dependencies ) ; const devDependencies = [ '@ezbackend/openapi' , '@ezbackend/db-ui' , 'ts-node-dev' , 'typescript' , '@types/node' , ] ; packageManager . addDependencies ( { packageJson : packageJson , installAsDevDependencies : true , } , devDependencies ) ; } export async function baseGenerator ( packageManager , options ) { if ( options . install ) installDependencies ( packageManager ) ; packageManager . addEzbCommandInScripts ( ) ; copyBoilerPlate ( ) ; } export function copyBoilerPlate ( ) { const boilerPlatePath = ( ) => { const defaultPath = path . resolve ( __dirname , '../../' , `frameworks/common` ) ; return defaultPath ; } ; const rootBoilerPlatePath = ( ) => { const defaultPath = path . resolve ( __dirname , '../../' , `frameworks/root-files` ) ; return defaultPath ; } ; const getTargetPath = ( ) => { return './src' ; } ; const getTargetRootPath = ( ) => { return `.` ; } ; fse . copySync ( boilerPlatePath ( ) , getTargetPath ( ) , { overwrite : true } ) ; fse . copySync ( rootBoilerPlatePath ( ) , getTargetRootPath ( ) , { overwrite : false , } ) ; }