()
| 155 | |
| 156 | // inspired by https://github.com/facebook/docusaurus/pull/3386 |
| 157 | checkPackageVersion(): void { |
| 158 | const coreVersion = Utils.getORMVersion(); |
| 159 | |
| 160 | if (process.env.MIKRO_ORM_ALLOW_VERSION_MISMATCH || coreVersion === '[[MIKRO_ORM_VERSION]]') { |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | const deps = this.getORMPackages(); |
| 165 | const exceptions = new Set(['nestjs', 'sql-highlighter', 'mongo-highlighter']); |
| 166 | const ormPackages = [...deps].filter( |
| 167 | d => d.startsWith('@mikro-orm/') && d !== '@mikro-orm/core' && !exceptions.has(d.substring('@mikro-orm/'.length)), |
| 168 | ); |
| 169 | |
| 170 | for (const ormPackage of ormPackages) { |
| 171 | const version = this.getORMPackageVersion(ormPackage); |
| 172 | |
| 173 | if (version != null && version !== coreVersion) { |
| 174 | throw new Error( |
| 175 | `Bad ${colors.cyan(ormPackage)} version ${colors.yellow('' + version)}.\n` + |
| 176 | `All official @mikro-orm/* packages need to have the exact same version as @mikro-orm/core (${colors.green(coreVersion)}).\n` + |
| 177 | `Only exceptions are packages that don't live in the 'mikro-orm' repository: ${[...exceptions].join(', ')}.\n` + |
| 178 | `Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`, |
| 179 | ); |
| 180 | } |
| 181 | } |
| 182 | }, |
| 183 | |
| 184 | /** |
| 185 | * Resolves and normalizes a series of path parts relative to each preceding part. |
nothing calls this directly
no test coverage detected