@@ -115,3 +115,40 @@ func DetectProjectType(dir fs.FS) (ProjectType, error) {
115115
116116 return ProjectTypeUnknown , errors .New ("project type could not be identified; expected package.json, requirements.txt, pyproject.toml, or lock files" )
117117}
118+
119+ // ValidateLockFiles checks if the required lock files exist for the given project type.
120+ // This ensures that dependency sync commands (e.g., uv sync, npm install) have been run
121+ // before deployment, preventing build failures.
122+ func ValidateLockFiles (dir fs.FS , projectType ProjectType ) error {
123+ switch projectType {
124+ case ProjectTypePythonUV :
125+ if ! util .FileExists (dir , "uv.lock" ) {
126+ return errors .New ("uv.lock file not found. Please run 'uv sync' to generate the lock file before deployment" )
127+ }
128+ case ProjectTypePythonPip :
129+ // Check if project uses poetry or pipenv which require lock files
130+ if util .FileExists (dir , "poetry.lock" ) {
131+ // Poetry project - lock file should already exist if detected
132+ return nil
133+ }
134+ if util .FileExists (dir , "Pipfile.lock" ) {
135+ // Pipenv project - lock file should already exist if detected
136+ return nil
137+ }
138+ // For requirements.txt projects, no lock file is required
139+ // pyproject.toml without poetry/pipenv also doesn't require a lock file
140+ return nil
141+ case ProjectTypeNode :
142+ // Check for any of the common lock files
143+ hasLockFile := util .FileExists (dir , "package-lock.json" ) ||
144+ util .FileExists (dir , "yarn.lock" ) ||
145+ util .FileExists (dir , "pnpm-lock.yaml" ) ||
146+ util .FileExists (dir , "bun.lockb" )
147+ if ! hasLockFile {
148+ return errors .New ("no lock file found (package-lock.json, yarn.lock, pnpm-lock.yaml, or bun.lockb). Please run 'npm install', 'yarn install', 'pnpm install', or 'bun install' to generate a lock file before deployment" )
149+ }
150+ case ProjectTypeUnknown :
151+ return errors .New ("unknown project type, cannot validate lock files" )
152+ }
153+ return nil
154+ }
0 commit comments