Skip to content
Merged
2 changes: 1 addition & 1 deletion apps/workers/workflow-workers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ ENV NODE_ENV=production
# Send SIGTERM and allow time to shutdown gracefully
STOPSIGNAL SIGTERM
# Start directly with node; no pnpm needed at runtime
CMD ["node", "dist/index.js"]
CMD ["node", "dist/apps/workers/workflow-workers/src/index.js"]

4 changes: 2 additions & 2 deletions apps/workers/workflow-workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"private": true,
"version": "0.1.0",
"type": "module",
"main": "dist/index.js",
"main": "dist/apps/workers/workflow-workers/src/index.js",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc && tsc-alias && tsc-esm-fix",
"start": "node dist/index.js"
"start": "node dist/apps/workers/workflow-workers/src/index.js"
},
"dependencies": {
"bullmq": "~5.56.0",
Expand Down
26 changes: 19 additions & 7 deletions apps/workers/workflow-workers/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,33 @@ import type { QueueEvents, Worker } from "bullmq"
import dotenv from "dotenv"
import type IORedis from "ioredis"
import path from "path"
import { getRedisConnection } from "shared/adapters/ioredis/client"
import { JOB_STATUS_CHANNEL } from "shared/entities/Channels"
import { JobStatusUpdateSchema } from "shared/entities/events/JobStatus"
import { fileURLToPath } from "url"

import { getRedisConnection } from "@/shared/adapters/ioredis/client"
import { JOB_STATUS_CHANNEL } from "@/shared/entities/Channels"
import { JobStatusUpdateSchema } from "@/shared/entities/events/JobStatus"

import { envSchema, type EnvVariables } from "./schemas"

let envLoaded = false

/**
* Environment loading strategy:
*
* - Docker production: Environment variables are loaded via `env_file` in docker-compose.yml
* before the container starts. The dotenv.config() calls below will find no .env files
* in the container (they are not copied), so they silently no-op. This is harmless.
*
* - Local development: dotenv.config() loads .env files from process.cwd() (repository root).
* Developers should provide .env.local or .env files at the repository root for local development.
*
* In both cases, envSchema.parse(process.env) validates that all required variables are present.
*/
function loadEnvFromWorkerRoot(): void {
if (envLoaded) return

const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const workerRoot = path.resolve(dirname, "..")
// Use process.cwd() as the worker root, which is where the process is started from
// This works correctly whether the dist structure is flat or nested
const workerRoot = process.cwd()

const nodeEnv = process.env.NODE_ENV ?? "development"

Expand Down
5 changes: 3 additions & 2 deletions apps/workers/workflow-workers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

*/
import { QueueEvents, Worker } from "bullmq"
import { getRedisConnection } from "shared/adapters/ioredis/client"
import { WORKFLOW_JOBS_QUEUE } from "shared/entities/Queue"

import { getRedisConnection } from "@/shared/adapters/ioredis/client"
import { WORKFLOW_JOBS_QUEUE } from "@/shared/entities/Queue"

import { handler } from "./handler"
import { getEnvVar, registerGracefulShutdown } from "./helper"
Expand Down
7 changes: 5 additions & 2 deletions apps/workers/workflow-workers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
/* Emit */
"rootDir": "./src",
"outDir": "./dist",
"noEmit": false,

Expand All @@ -11,7 +10,11 @@
"module": "ES2020",
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"allowImportingTsExtensions": false
"allowImportingTsExtensions": false,

"paths": {
"@/shared/*": ["shared/src/*"]
}
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist"]
Expand Down
2 changes: 1 addition & 1 deletion shared/src/adapters/ioredis/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import IORedis, { RedisOptions } from "ioredis"
import IORedis, { type RedisOptions } from "ioredis"

// Roles describe how a connection is used. Some can be shared safely, others must be dedicated.
export type RedisRole =
Expand Down
3 changes: 2 additions & 1 deletion shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@shared/*": ["./src/*"]
"@shared/*": ["./src/*"], // @deprecated, migrate to using "@/shared/*" instead
"@/shared/*": ["./src/*"]
},

/* Emit */
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"@/lib/*": ["lib/*"],
"@/components/*": ["components/*"],
"@/styles/*": ["styles/*"],
"@shared/*": ["shared/src/*"]
"@shared/*": ["shared/src/*"], // @deprecated, migrate to using "@/shared/*" instead
"@/shared/*": ["shared/src/*"]
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the tsconfig.json file to understand the context
cat -n tsconfig.json | head -30

Repository: youngchingjui/issue-to-pr

Length of output: 1096


🏁 Script executed:

# Search for any remaining usages of the deprecated "@shared/*" alias
rg -n '@shared/' --type=ts --type=js -g '!node_modules/**' -g '!**/dist/**' -g '!**/*.d.ts' 2>/dev/null | head -20

Repository: youngchingjui/issue-to-pr

Length of output: 2214


🏁 Script executed:

# Also check for dynamic imports with the deprecated alias
rg -n "import\(['\"]\@shared" --type=ts --type=js -g '!node_modules/**' -g '!**/dist/**' 2>/dev/null

Repository: youngchingjui/issue-to-pr

Length of output: 51


🏁 Script executed:

# Check if there are any other files that might reference this
rg -l '@shared/' --type=ts --type=js --type=json -g '!node_modules/**' -g '!**/dist/**' 2>/dev/null | head -20

Repository: youngchingjui/issue-to-pr

Length of output: 760


Migration from "@shared/" to "@/shared/" is incomplete and must be completed before this change can be merged.

The new "@/shared/" alias follows the consistent naming pattern with other path mappings. However, the codebase still contains numerous active imports using the deprecated "@shared/" alias that must be migrated:

  • shared/src/ui/button.tsx, shared/src/ui/alert.tsx
  • lib/workflows/createDependentPR.ts, lib/workflows/createDependentPR.formatMessage.ts
  • lib/agents/DependentPRAgent.ts
  • lib/github/auth.ts, lib/github/users.ts
  • shared/src/adapters/github/octokit/graphql/pullRequest.reader.ts, pullRequest.writer.ts
  • shared/src/lib/tools/UpdatePRTool.ts
  • __tests__/shared/usecases/generateBranchName.test.ts
  • And additional files

Update all imports to use "@/shared/" instead of "@shared/" before merging this change.

πŸ€– Prompt for AI Agents
In tsconfig.json around lines 24 to 25, the deprecated "@shared/*" path alias
remains and many files still import using it; update all imports to use the new
"@/shared/*" alias: search the codebase for occurrences of "@shared/" (including
the listed files: shared/src/ui/button.tsx, shared/src/ui/alert.tsx,
lib/workflows/createDependentPR.ts,
lib/workflows/createDependentPR.formatMessage.ts,
lib/agents/DependentPRAgent.ts, lib/github/auth.ts, lib/github/users.ts,
shared/src/adapters/github/octokit/pullRequest.reader.ts, pullRequest.writer.ts,
shared/src/lib/tools/UpdatePRTool.ts,
__tests__/shared/usecases/generateBranchName.test.ts, etc.) and replace them
with "@/shared/"; update any import typings or relative paths if necessary,
remove the deprecated comment in tsconfig or keep but mark migrated, run the
TypeScript build and tests to catch remaining references and fix any resulting
import path errors before merging.

},

/* TO SORT */
Expand Down