1
1
import colors from 'colors' ;
2
2
import fs from 'fs' ;
3
3
import path from 'path' ;
4
+ import pkgJson from '../../package.json' ;
4
5
import { PackageManagers , ensurePackage , installPackage } from '../../utils/pkg-utils' ;
5
6
import { getVersion } from '../../utils/version-utils' ;
6
7
import { CliError } from '../cli-error' ;
@@ -50,8 +51,10 @@ export async function init(projectPath: string, options: Options) {
50
51
}
51
52
}
52
53
53
- ensurePackage ( 'prisma' , true , options . packageManager , 'latest' , projectPath ) ;
54
- ensurePackage ( '@prisma/client' , false , options . packageManager , 'latest' , projectPath ) ;
54
+ const latestSupportedPrismaVersion = getLatestSupportedPrismaVersion ( ) ;
55
+
56
+ ensurePackage ( 'prisma' , true , options . packageManager , latestSupportedPrismaVersion , projectPath ) ;
57
+ ensurePackage ( '@prisma/client' , false , options . packageManager , latestSupportedPrismaVersion , projectPath ) ;
55
58
56
59
const tag = options . tag ?? getVersion ( ) ;
57
60
installPackage ( 'zenstack' , true , options . packageManager , tag , projectPath ) ;
@@ -75,3 +78,15 @@ Moving forward please edit this file and run "zenstack generate" to regenerate P
75
78
await checkNewVersion ( ) ;
76
79
}
77
80
}
81
+
82
+ function getLatestSupportedPrismaVersion ( ) {
83
+ const versionSpec = pkgJson . peerDependencies . prisma ;
84
+ let maxVersion : string | undefined ;
85
+ const hyphen = versionSpec . indexOf ( '-' ) ;
86
+ if ( hyphen > 0 ) {
87
+ maxVersion = versionSpec . substring ( hyphen + 1 ) . trim ( ) ;
88
+ } else {
89
+ maxVersion = versionSpec ;
90
+ }
91
+ return maxVersion ?? 'latest' ;
92
+ }
0 commit comments