forked from MichalLytek/type-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
077a8e9
commit e15b4d0
Showing
7 changed files
with
53 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import "reflect-metadata"; | ||
import * as typeGraphQL from "type-graphql"; | ||
import packageJson from "../package.json"; | ||
|
||
const versionInfoString = `${typeGraphQL.versionInfo.major}.${typeGraphQL.versionInfo.minor}.${ | ||
typeGraphQL.versionInfo.patch | ||
}${typeGraphQL.versionInfo.preReleaseTag ?? ""}`; | ||
|
||
const versionPeerDependenciesString = JSON.stringify(typeGraphQL.versionPeerDependencies); | ||
|
||
const packageJsonPeerDependenciesString = JSON.stringify(packageJson.peerDependencies); | ||
|
||
if (typeGraphQL.version !== packageJson.version) { | ||
throw new Error( | ||
`version (${typeGraphQL.version}) != package.json.version (${packageJson.version})`, | ||
); | ||
} | ||
|
||
if (typeGraphQL.version !== versionInfoString) { | ||
throw new Error(`version (${typeGraphQL.version}) != versionInfo (${versionInfoString})`); | ||
} | ||
|
||
if (versionPeerDependenciesString !== packageJsonPeerDependenciesString) { | ||
throw new Error( | ||
`versionPeerDependencies (${versionPeerDependenciesString}) != package.json.peerDependencies (${packageJsonPeerDependenciesString})`, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
import * as graphql from "graphql"; | ||
import semVer from "semver"; | ||
import { UnmetGraphQLPeerDependencyError } from "@/errors"; | ||
|
||
export function getInstalledGraphQLVersion(): string { | ||
// eslint-disable-next-line global-require | ||
const graphqlPackageJson = require("graphql/package.json"); | ||
return graphqlPackageJson.version; | ||
} | ||
|
||
export function getPeerDependencyGraphQLRequirement(): string { | ||
// eslint-disable-next-line global-require | ||
const ownPackageJson = require("../../package.json"); | ||
return ownPackageJson.peerDependencies.graphql; | ||
} | ||
import { versionPeerDependencies } from "@/version"; | ||
|
||
export function ensureInstalledCorrectGraphQLPackage() { | ||
const installedVersion = getInstalledGraphQLVersion(); | ||
const versionRequirement = getPeerDependencyGraphQLRequirement(); | ||
|
||
if (!semVer.satisfies(installedVersion, versionRequirement)) { | ||
if (!semVer.satisfies(graphql.version, versionPeerDependencies.graphql)) { | ||
throw new UnmetGraphQLPeerDependencyError(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const version = "2.0.0" as string; | ||
|
||
export const versionInfo = Object.freeze({ | ||
major: 2 as number, | ||
minor: 0 as number, | ||
patch: 0 as number, | ||
preReleaseTag: null as string | null, | ||
}); | ||
|
||
export const versionPeerDependencies = Object.freeze({ | ||
"class-validator": ">=0.14.0" as string, | ||
graphql: "^16.6.0" as string, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters