MCPcopy
hub / github.com/apify/crawlee / getNextVersion

Function getNextVersion

scripts/copy.ts:49–76  ·  view source on GitHub ↗

* Checks next dev version number based on the `crawlee` 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

47 * We always use this package, so we ensure the version is the same for each package in the monorepo.
48 */
49function getNextVersion() {
50 const versions: string[] = [];
51
52 try {
53 const versionString = execSync(`npm show @crawlee/core versions --json`, { encoding: 'utf8', stdio: 'pipe' });
54 const parsed = JSON.parse(versionString) as string[];
55 versions.push(...parsed);
56 } catch {
57 // the package might not have been published yet
58 }
59
60 const version = getRootVersion();
61
62 if (versions.some((v) => v === version)) {
63 console.error(
64 `before-deploy: A release with version ${version} already exists. Please increment version accordingly.`,
65 );
66 process.exit(1);
67 }
68
69 const preid = options.preid ?? 'alpha';
70 const prereleaseNumbers = versions
71 .filter((v) => v.startsWith(`${version}-${preid}.`))
72 .map((v) => Number(v.match(/\.(\d+)$/)?.[1]));
73 const lastPrereleaseNumber = Math.max(-1, ...prereleaseNumbers);
74
75 return `${version}-${preid}.${lastPrereleaseNumber + 1}`;
76}
77
78// as we publish only the dist folder, we need to copy some meta files inside (readme/license/package.json)
79// also changes paths inside the copied `package.json` (`dist/index.js` -> `index.js`)

Callers 1

copy.tsFile · 0.85

Calls 5

execSyncFunction · 0.85
getRootVersionFunction · 0.85
parseMethod · 0.80
pushMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…