MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / getNextVersion

Function getNextVersion

scripts/copy.mjs:76–102  ·  view source on GitHub ↗

* Checks next dev version number based on the `@mikro-orm/core` meta package via `npm show`. * We always use this package, so we ensure the version is the same for each package in the monorepo.

()

Source from the content-addressed store, hash-verified

74 * We always use this package, so we ensure the version is the same for each package in the monorepo.
75 */
76async function getNextVersion() {
77 const versions = [];
78
79 try {
80 const versionString = execSync(`npm show @mikro-orm/core versions --json`, { encoding: 'utf8', stdio: 'pipe' });
81 const parsed = JSON.parse(versionString);
82 versions.push(...parsed);
83 } catch {
84 // the package might not have been published yet
85 }
86
87 const version = await getRootVersion();
88
89 if (versions.some(v => v === version)) {
90 // eslint-disable-next-line no-console
91 console.error(`before-deploy: A release with version ${version} already exists. Please increment version accordingly.`);
92 process.exit(1);
93 }
94
95 const preid = options.preid ?? 'dev';
96 const prereleaseNumbers = versions
97 .filter(v => v.startsWith(`${version}-${preid}.`))
98 .map(v => Number(v.match(/\.(\d+)$/)?.[1]));
99 const lastPrereleaseNumber = Math.max(-1, ...prereleaseNumbers);
100
101 return `${version}-${preid}.${lastPrereleaseNumber + 1}`;
102}
103
104if (options.canary) {
105 const pkgJson = require(pkgPath);

Callers 1

copy.mjsFile · 0.85

Calls 5

getRootVersionFunction · 0.85
pushMethod · 0.80
filterMethod · 0.80
errorMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected