|
@@ -21,6 +21,7 @@ export type RenderContext = Omit<Inputs, 'programAddress' | 'solanaVersion'> & {
|
|
|
packageManager: PackageManager;
|
|
packageManager: PackageManager;
|
|
|
solanaVersion: string;
|
|
solanaVersion: string;
|
|
|
solanaVersionDetected: string;
|
|
solanaVersionDetected: string;
|
|
|
|
|
+ solanaVersionWithoutPatch: string;
|
|
|
targetDirectory: string;
|
|
targetDirectory: string;
|
|
|
templateDirectory: string;
|
|
templateDirectory: string;
|
|
|
toolchain: string;
|
|
toolchain: string;
|
|
@@ -50,6 +51,10 @@ export function getRenderContext({
|
|
|
inputs.solanaVersion,
|
|
inputs.solanaVersion,
|
|
|
solanaVersionDetected
|
|
solanaVersionDetected
|
|
|
);
|
|
);
|
|
|
|
|
+ const solanaVersionWithoutPatch = toMinorSolanaVersion(
|
|
|
|
|
+ language,
|
|
|
|
|
+ solanaVersion
|
|
|
|
|
+ );
|
|
|
const toolchain = getToolchainFromSolanaVersion(solanaVersion);
|
|
const toolchain = getToolchainFromSolanaVersion(solanaVersion);
|
|
|
|
|
|
|
|
// Directories.
|
|
// Directories.
|
|
@@ -75,6 +80,7 @@ export function getRenderContext({
|
|
|
programDirectory,
|
|
programDirectory,
|
|
|
solanaVersion,
|
|
solanaVersion,
|
|
|
solanaVersionDetected,
|
|
solanaVersionDetected,
|
|
|
|
|
+ solanaVersionWithoutPatch,
|
|
|
targetDirectory,
|
|
targetDirectory,
|
|
|
templateDirectory,
|
|
templateDirectory,
|
|
|
toolchain,
|
|
toolchain,
|
|
@@ -96,7 +102,23 @@ function resolveSolanaVersion(
|
|
|
inputVersion: string | undefined,
|
|
inputVersion: string | undefined,
|
|
|
detectedVersion: string
|
|
detectedVersion: string
|
|
|
): string {
|
|
): string {
|
|
|
- return inputVersion ?? toMinorSolanaVersion(language, detectedVersion);
|
|
|
|
|
|
|
+ if (!inputVersion) {
|
|
|
|
|
+ return detectedVersion;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!inputVersion.match(/^\d+\.\d+(\.\d+)?$/)) {
|
|
|
|
|
+ throw new Error(
|
|
|
|
|
+ language.errors.invalidSolanaVersion.replace('$version', inputVersion)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ const versionSegments = inputVersion.split('.');
|
|
|
|
|
+ if (versionSegments.length === 3) {
|
|
|
|
|
+ return inputVersion;
|
|
|
|
|
+ }
|
|
|
|
|
+ const map: Record<string, string> = {
|
|
|
|
|
+ '1.17': '1.17.34',
|
|
|
|
|
+ '1.18': '1.18.18',
|
|
|
|
|
+ };
|
|
|
|
|
+ return map[inputVersion] ?? `${inputVersion}.0`;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function resolveAnchorVersion(detectedVersion: string | undefined): string {
|
|
function resolveAnchorVersion(detectedVersion: string | undefined): string {
|