diff --git a/apps/data-service/tsconfig.json b/apps/data-service/tsconfig.json index c6f8cc6..bf5e1f4 100644 --- a/apps/data-service/tsconfig.json +++ b/apps/data-service/tsconfig.json @@ -4,7 +4,6 @@ "outDir": "./dist", "rootDir": "./src", "declaration": true, - "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "esModuleInterop": true }, diff --git a/libs/config/tsconfig.json b/libs/config/tsconfig.json index 0e77acd..2367e22 100644 --- a/libs/config/tsconfig.json +++ b/libs/config/tsconfig.json @@ -4,12 +4,16 @@ "outDir": "./dist", "rootDir": "./src", "declaration": true, - "moduleResolution": "node", - "module": "CommonJS", - "target": "ES2020" + "declarationMap": true, + "sourceMap": false }, "include": [ "src/**/*" ], - "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"] + "exclude": [ + "dist", + "node_modules", + "**/*.test.ts", + "**/*.spec.ts" + ] } diff --git a/libs/logger/tsconfig.json b/libs/logger/tsconfig.json index 7f9b0b2..2367e22 100644 --- a/libs/logger/tsconfig.json +++ b/libs/logger/tsconfig.json @@ -3,13 +3,17 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "declaration": true + "declaration": true, + "declarationMap": true, + "sourceMap": false }, "include": [ "src/**/*" ], - "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"], - "references": [ - { "path": "../config" } + "exclude": [ + "dist", + "node_modules", + "**/*.test.ts", + "**/*.spec.ts" ] } diff --git a/package.json b/package.json index df5c986..1eb6588 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "version": "1.0.0", "description": "Advanced trading bot with microservice architecture", + "type": "module", "scripts": { "dev": "turbo run dev", "build": "turbo run build", @@ -16,9 +17,12 @@ "test:libs": "turbo run test --filter='./libs/*'", "test:apps": "turbo run test --filter=./apps/*/*", "lint": "turbo run lint", - "clean": "turbo run clean", "start": "turbo run start", - "clean:dist": "rimraf **/dist", + "clean": "turbo run clean", + "clean:dist": "powershell ./scripts/clean.ps1 -dist", + "clean:modules": "powershell ./scripts/clean.ps1 -modules", + "clean:all": "powershell ./scripts/clean.ps1 -all", + "clean:fresh": "powershell ./scripts/clean.ps1 -fresh", "backtest": "turbo run backtest", "docker:start": "powershell ./scripts/docker.ps1 start", "docker:stop": "powershell ./scripts/docker.ps1 stop", diff --git a/scripts/build-libs.ps1 b/scripts/build-libs.ps1 index 06c6af7..32ece98 100644 --- a/scripts/build-libs.ps1 +++ b/scripts/build-libs.ps1 @@ -5,13 +5,25 @@ Write-Host "Building and installing new libraries..." -ForegroundColor Cyan # Build order is important due to dependencies $libs = @( "types", # Base types - no dependencies - "logger", # Logging utilities - depends on types "config", # Configuration - depends on types - "utils", # Utilities - depends on types and config "cache", # Cache - depends on types and logger - "http", # HTTP client - depends on types, config, logger + "logger", # Logging utilities - depends on types + "utils", # Utilities - depends on types and config + + # Database clients "postgres-client", # PostgreSQL client - depends on types, config, logger "mongodb-client", # MongoDB client - depends on types, config, logger - "questdb-client" # QuestDB client - depends on types, config, logger + "questdb-client", # QuestDB client - depends on types, config, logger + + # Service libraries + "cache", # Cache - depends on types and logger + "http", # HTTP client - depends on types, config, logger + "event-bus", # Event bus - depends on types, logger + "shutdown", # Shutdown - depends on types, logger + + # Engine libraries + "data-frame", # Data frame - depends on types, utils + "vector-engine", # Vector engine - depends on types, utils, data-frame + "strategy-engine" # Strategy engine - depends on types, utils, event-bus ) # Build each library in order diff --git a/scripts/clean.ps1 b/scripts/clean.ps1 new file mode 100644 index 0000000..79a5ebe --- /dev/null +++ b/scripts/clean.ps1 @@ -0,0 +1,59 @@ +param( + [switch]$modules, + [switch]$dist, + [switch]$all, + [switch]$fresh +) + +function Remove-DirectoriesByName { + param([string]$Name, [string]$Description) + + Write-Host "Removing $Description..." -ForegroundColor Blue + $directories = Get-ChildItem -Path . -Name $Name -Recurse -Directory -ErrorAction SilentlyContinue + + if ($directories.Count -gt 0) { + Write-Host "Found $($directories.Count) $Description to remove" -ForegroundColor Gray + $directories | ForEach-Object { + Remove-Item $_ -Recurse -Force -ErrorAction SilentlyContinue + Write-Host " Removed: $_" -ForegroundColor Gray + } + } else { + Write-Host "No $Description found" -ForegroundColor Gray + } +} + +Write-Host "Starting cleanup..." -ForegroundColor Yellow + +if ($all -or $fresh) { + Remove-DirectoriesByName "node_modules" "node_modules directories" + Remove-DirectoriesByName "dist" "dist directories" + + Write-Host "Removing lock files..." -ForegroundColor Blue + Remove-Item -Path "bun.lockb" -Force -ErrorAction SilentlyContinue + Get-ChildItem -Path . -Name "bun.lockb" -Recurse -File | Remove-Item -Force -ErrorAction SilentlyContinue + + # Remove turbo clean since PowerShell already cleaned everything + Write-Host "Cleanup complete - no need for turbo clean" -ForegroundColor Blue +} +elseif ($modules) { + Remove-DirectoriesByName "node_modules" "node_modules directories" + + Write-Host "Removing lock files..." -ForegroundColor Blue + Remove-Item -Path "bun.lockb" -Force -ErrorAction SilentlyContinue + Get-ChildItem -Path . -Name "bun.lockb" -Recurse -File | Remove-Item -Force -ErrorAction SilentlyContinue +} +elseif ($dist) { + Remove-DirectoriesByName "dist" "dist directories" +} +else { + Write-Host "Running turbo clean..." -ForegroundColor Blue + # Only run turbo clean for the default case + turbo run clean +} + +if ($fresh) { + Write-Host "Installing dependencies..." -ForegroundColor Green + bun install +} + +Write-Host "Cleanup complete!" -ForegroundColor Green \ No newline at end of file diff --git a/tsconfig.app.json b/tsconfig.app.json index 168d88b..c4a9fd6 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -3,8 +3,6 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "module": "ESNext", - "moduleResolution": "bundler", "types": ["bun-types"] }, "include": ["src/**/*"], diff --git a/tsconfig.json b/tsconfig.json index 07a4f38..2f3328c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,9 @@ "compilerOptions": { // JavaScript output target version "target": "ES2022", - // Module configuration for different project types + // Module configuration for different project types "module": "ESNext", - "moduleResolution": "node", + "moduleResolution": "bundler", "composite": true, // Type checking @@ -14,6 +14,7 @@ "strictNullChecks": true, "noImplicitThis": true, "alwaysStrict": true, + "declarationMap": true, // Module interoperability "esModuleInterop": true, @@ -33,25 +34,32 @@ "paths": { "@stock-bot/*": ["libs/*/src"] } - }, "exclude": [ "node_modules", "dist" - ], "references": [ - { "path": "./libs/config" }, - { "path": "./libs/http" }, - { "path": "./libs/logger" }, - { "path": "./libs/mongodb-client" }, - { "path": "./libs/postgres-client" }, - { "path": "./libs/questdb-client" }, + ], + "references": [ + // Core libraries first { "path": "./libs/types" }, - { "path": "./libs/cache" }, + { "path": "./libs/config" }, + { "path": "./libs/logger" }, { "path": "./libs/utils" }, - { "path": "./libs/event-bus" }, - { "path": "./libs/data-frame" }, - { "path": "./libs/strategy-engine" }, - { "path": "./libs/vector-engine" }, - ] -} + // Database clients + { "path": "./libs/postgres-client" }, + { "path": "./libs/mongodb-client" }, + { "path": "./libs/questdb-client" }, + + // Service libraries + { "path": "./libs/cache" }, + { "path": "./libs/http" }, + { "path": "./libs/event-bus" }, + { "path": "./libs/shutdown" }, + + // Engine libraries + { "path": "./libs/data-frame" }, + { "path": "./libs/vector-engine" }, + { "path": "./libs/strategy-engine" } + ] +} \ No newline at end of file