Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions packages/schema/src/cli/actions/init.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import colors from 'colors';
import fs from 'fs';
import path from 'path';
import pkgJson from '../../package.json';
import { PackageManagers, ensurePackage, installPackage } from '../../utils/pkg-utils';
import { getVersion } from '../../utils/version-utils';
import { CliError } from '../cli-error';
Expand Down Expand Up @@ -50,8 +51,10 @@ export async function init(projectPath: string, options: Options) {
}
}

ensurePackage('prisma', true, options.packageManager, 'latest', projectPath);
ensurePackage('@prisma/client', false, options.packageManager, 'latest', projectPath);
const latestSupportedPrismaVersion = getLatestSupportedPrismaVersion();

ensurePackage('prisma', true, options.packageManager, latestSupportedPrismaVersion, projectPath);
ensurePackage('@prisma/client', false, options.packageManager, latestSupportedPrismaVersion, projectPath);

const tag = options.tag ?? getVersion();
installPackage('zenstack', true, options.packageManager, tag, projectPath);
Expand All @@ -75,3 +78,15 @@ Moving forward please edit this file and run "zenstack generate" to regenerate P
await checkNewVersion();
}
}

function getLatestSupportedPrismaVersion() {
const versionSpec = pkgJson.peerDependencies.prisma;
let maxVersion: string | undefined;
const hyphen = versionSpec.indexOf('-');
if (hyphen > 0) {
maxVersion = versionSpec.substring(hyphen + 1).trim();
} else {
maxVersion = versionSpec;
}
return maxVersion ?? 'latest';
}
1 change: 1 addition & 0 deletions packages/schema/src/package.json
3 changes: 2 additions & 1 deletion tests/integration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"resolveJsonModule": true
},
"include": ["**/*.ts", "**/*.d.ts"]
}
Loading