@@ -125,12 +125,39 @@ rec {
125125 fromPnpmLock =
126126 path :
127127 let
128+ textAfter = keyword : text : builtins . elemAt ( builtins . split keyword text ) 1 ;
129+ textBefore = keyword : text : builtins . elemAt ( builtins . split keyword text ) 0 ;
130+ parsePnpmLockVersion =
131+ pnpmLock :
132+ if nixpkgs . lib . strings . hasPrefix "lockfileVersion: 5" pnpmLock then
133+ "5"
134+ else if nixpkgs . lib . strings . hasPrefix "lockfileVersion: '6" pnpmLock then
135+ "6"
136+ else
137+ "9" ;
138+ pnpmLockParsers = {
139+ # example line:
140+ # /@prisma/engines-version/5.1.1-1.6a3747c37ff169c90047725a05a6ef02e32ac97e:
141+ "5" =
142+ pnpmLock :
143+ builtins . elemAt ( builtins . match ".*@prisma/engines-version/.*\\ .([0-9a-f]{40}):.*" pnpmLock ) 0 ;
144+
145+ # example line:
146+ 147+ "6" =
148+ pnpmLock :
149+ builtins . elemAt ( builtins . match ".*@prisma/engines-version@.*\\ .([0-9a-f]{40}):.*" pnpmLock ) 0 ;
150+
151+ # exmple line:
152+ # '@prisma/engines-version@5.15.0-29.12e25d8d06f6ea5a0252864dd9a03b1bb51f3022':
153+ "9" =
154+ pnpmLock :
155+ builtins . elemAt ( builtins . match ".*@prisma/engines-version@.*\\ .([0-9a-f]{40})'.*" pnpmLock ) 0 ;
156+ } ;
128157 pnpmLock = builtins . readFile path ;
129- splitCharacter = if nixpkgs . lib . strings . hasPrefix "lockfileVersion: 5" pnpmLock then "/" else "@" ;
130- version = builtins . elemAt ( builtins . split ":" (
131- builtins . elemAt ( builtins . split ( "@prisma/engines-version" + splitCharacter ) pnpmLock ) 2
132- ) ) 0 ;
133- commit = nixpkgs . lib . lists . last ( nixpkgs . lib . strings . splitString "." version ) ;
158+ pnpmLockVersion = parsePnpmLockVersion pnpmLock ;
159+ pnpmLockParser = pnpmLockParsers . ${ pnpmLockVersion } ;
160+ commit = pnpmLockParser pnpmLock ;
134161 in
135162 fromCommit commit ;
136163 fromNpmLock =
@@ -144,5 +171,5 @@ rec {
144171 packageLock . packages . ${ "node_modules/@prisma/engines-version" } . version ;
145172 commit = nixpkgs . lib . lists . last ( nixpkgs . lib . strings . splitString "." version ) ;
146173 in
147- builtins . trace commit ( fromCommit commit ) ;
174+ fromCommit commit ;
148175}
0 commit comments