mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-28 06:46:24 +00:00
fix(server,forgeCLI): route and schema template file generation is now run in forgeCLI before starting the server
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
"type": "module",
|
||||
"main": "./dist/server.js",
|
||||
"scripts": {
|
||||
"dev": "tsx watch --env-file=../env/.env.local ./src/index.ts",
|
||||
"dev": "echo \"PLEASE USE \"bun forge dev\" INSTEAD\"",
|
||||
"types": "bun run tsc -b",
|
||||
"build": "bun build ./src/index.ts --target bun --minify --production --outfile=./dist/server.js",
|
||||
"start": "NODE_ENV=production bun --env-file=../env/.env.local ./src/index.ts",
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import { LoggingService } from '@functions/logging/loggingService'
|
||||
|
||||
const ROOT_DIR = path.resolve(import.meta.dirname.split('core')[0], 'core')
|
||||
|
||||
/**
|
||||
* Initializes the route and schema files.
|
||||
* Creates the files from templates if they do not exist.
|
||||
*/
|
||||
export default function initRouteAndSchemaFiles(): void {
|
||||
const appRoutesPath = path.resolve(ROOT_DIR, 'routes/app.routes.ts')
|
||||
|
||||
const schemaPath = path.resolve(ROOT_DIR, 'schema.ts')
|
||||
|
||||
const templatesDir = path.resolve(ROOT_DIR, 'templates')
|
||||
|
||||
if (!fs.existsSync(appRoutesPath)) {
|
||||
LoggingService.info(
|
||||
'app.routes.ts not found, creating from template...',
|
||||
'INIT'
|
||||
)
|
||||
fs.copyFileSync(path.join(templatesDir, 'example.routes.ts'), appRoutesPath)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(schemaPath)) {
|
||||
LoggingService.info(
|
||||
'schema.ts not found, creating from template...',
|
||||
'INIT'
|
||||
)
|
||||
fs.copyFileSync(path.join(templatesDir, 'example.schema.ts'), schemaPath)
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ import fs from 'fs'
|
||||
import { createServer } from 'node:http'
|
||||
|
||||
import checkDB from '@functions/database/dbUtils'
|
||||
import { ensureKeysExist } from '@functions/encryption'
|
||||
import ensureCredentials from '@functions/initialization/ensureCredentials'
|
||||
import initRouteAndSchemaFiles from '@functions/initialization/initRouteAndSchemaFiles'
|
||||
import { LocaleService } from '@functions/initialization/localeService'
|
||||
import traceRouteStack from '@functions/initialization/traceRouteStack'
|
||||
import updateLocaleSubmodules from '@functions/initialization/updateLocaleSubmodules'
|
||||
@@ -35,7 +33,6 @@ async function main(): Promise<void> {
|
||||
updateLocaleSubmodules()
|
||||
LocaleService.validateAndLoad()
|
||||
ensureRootName()
|
||||
initRouteAndSchemaFiles()
|
||||
ensureDirectories()
|
||||
ensureCredentials()
|
||||
await checkDB()
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
executeCommand,
|
||||
killExistingProcess
|
||||
} from '@/utils/helpers'
|
||||
import initRouteAndSchemaFiles from '@/utils/initRouteAndSchemaFiles'
|
||||
import CLILoggingService from '@/utils/logging'
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,9 @@ export const SERVICE_COMMANDS: Record<string, ServiceConfig> = {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
return 'bun run dev'
|
||||
initRouteAndSchemaFiles()
|
||||
|
||||
return 'bun tsx watch --env-file=../env/.env.local ./src/index.ts'
|
||||
},
|
||||
cwd: 'server'
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import CLILoggingService from './logging'
|
||||
import { generateDatabaseSchemas } from '@/commands/modules/functions'
|
||||
|
||||
const ROOT_DIR = path.resolve(
|
||||
import.meta.dirname.split('tools')[0],
|
||||
@@ -26,6 +27,8 @@ export default function initRouteAndSchemaFiles(): {
|
||||
if (!fs.existsSync(schemaPath)) {
|
||||
CLILoggingService.info('schema.ts not found, creating from template...')
|
||||
fs.copyFileSync(path.join(templatesDir, 'example.schema.ts'), schemaPath)
|
||||
|
||||
generateDatabaseSchemas()
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user