Stop rejecting application install when APP_VERSION is wrong (#20443)
as title allows to install https://github.com/JordanChoo/twenty-multi-pipeline locally
This commit is contained in:
+1
-1
@@ -137,7 +137,7 @@ export class ApplicationInstallService {
|
||||
resolvedPackage.packageJson.engines?.['twenty'];
|
||||
|
||||
const versionValidation =
|
||||
this.applicationVersionValidationService.validateServerCompatibility(
|
||||
await this.applicationVersionValidationService.validateServerCompatibility(
|
||||
requiredServerVersion,
|
||||
);
|
||||
|
||||
|
||||
+2
@@ -7,11 +7,13 @@ import { ApplicationEntity } from 'src/engine/core-modules/application/applicati
|
||||
import { FileStorageModule } from 'src/engine/core-modules/file-storage/file-storage.module';
|
||||
import { FileEntity } from 'src/engine/core-modules/file/entities/file.entity';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { UpgradeModule } from 'src/engine/core-modules/upgrade/upgrade.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
FileStorageModule,
|
||||
TwentyConfigModule,
|
||||
UpgradeModule,
|
||||
TypeOrmModule.forFeature([FileEntity, ApplicationEntity]),
|
||||
],
|
||||
providers: [
|
||||
|
||||
+15
-10
@@ -2,8 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import semver from 'semver';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { UpgradeMigrationService } from 'src/engine/core-modules/upgrade/services/upgrade-migration.service';
|
||||
|
||||
export type VersionValidationFailureReason =
|
||||
| 'INVALID_REQUIRED_VERSION'
|
||||
@@ -20,11 +19,13 @@ export type VersionValidationResult =
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationVersionValidationService {
|
||||
constructor(private readonly twentyConfigService: TwentyConfigService) {}
|
||||
constructor(
|
||||
private readonly upgradeMigrationService: UpgradeMigrationService,
|
||||
) {}
|
||||
|
||||
validateServerCompatibility(
|
||||
async validateServerCompatibility(
|
||||
requiredServerVersion: string | undefined,
|
||||
): VersionValidationResult {
|
||||
): Promise<VersionValidationResult> {
|
||||
if (!isDefined(requiredServerVersion)) {
|
||||
return { compatible: true };
|
||||
}
|
||||
@@ -37,21 +38,25 @@ export class ApplicationVersionValidationService {
|
||||
};
|
||||
}
|
||||
|
||||
const serverVersion = this.twentyConfigService.get('APP_VERSION');
|
||||
const inferredServerVersion =
|
||||
await this.upgradeMigrationService.getInferredVersion();
|
||||
|
||||
if (!isDefined(serverVersion) || !isDefined(semver.valid(serverVersion))) {
|
||||
if (
|
||||
!isDefined(inferredServerVersion) ||
|
||||
!isDefined(semver.valid(inferredServerVersion))
|
||||
) {
|
||||
return {
|
||||
compatible: false,
|
||||
reason: 'INVALID_SERVER_VERSION',
|
||||
message: `Cannot verify server compatibility: APP_VERSION "${serverVersion ?? 'undefined'}" is not a valid semver version. Self-hosted instances must set a valid APP_VERSION.`,
|
||||
message: `Cannot verify server compatibility: inferred server version "${inferredServerVersion ?? 'undefined'}" is not a valid semver version.`,
|
||||
};
|
||||
}
|
||||
|
||||
if (!semver.satisfies(serverVersion, requiredServerVersion)) {
|
||||
if (!semver.satisfies(inferredServerVersion, requiredServerVersion)) {
|
||||
return {
|
||||
compatible: false,
|
||||
reason: 'INCOMPATIBLE',
|
||||
message: `App requires Twenty server ${requiredServerVersion} but this server is ${serverVersion}.`,
|
||||
message: `App requires Twenty server ${requiredServerVersion} but this server is ${inferredServerVersion}.`,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ export class ApplicationTarballService {
|
||||
const requiredServerVersion = packageJson?.engines?.twenty;
|
||||
|
||||
const versionValidation =
|
||||
this.applicationVersionValidationService.validateServerCompatibility(
|
||||
await this.applicationVersionValidationService.validateServerCompatibility(
|
||||
requiredServerVersion,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user