Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions scripts/check-is-release.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import getReleasePlan from '@changesets/get-release-plan';

/** Check if a "next" / development release is necessary based on the presence of changesets */
/**
* Checks if a "next" or development release is necessary based on the presence of changesets.
* Outputs "true" or "false" to stdout.
*/
async function checkIsRelease() {
const releasePlan = await getReleasePlan(process.cwd());
const currentDir = process.cwd();
const packageJsonPath = `${currentDir}/cli/package.json`;

try {
const packageJson = await Bun.file(process.cwd() + '/cli/package.json').json();
const newNextVersion = releasePlan.releases.find((release) => release.name === packageJson.name)?.newVersion;
const releasePlan = await getReleasePlan(currentDir);
const packageJson = await Bun.file(packageJsonPath).json();

if (newNextVersion == null) {
await Bun.write(Bun.stdout, 'false\n');
} else {
await Bun.write(Bun.stdout, 'true\n');
}
const newNextVersion = releasePlan?.releases?.find(
(release) => release.name === packageJson.name
)?.newVersion;

await Bun.write(Bun.stdout, `${newNextVersion != null}\n`);
} catch (error) {
console.log(error);
console.error('Error during release check:', error);
process.exit(1);
}
}

// Run the release check
await checkIsRelease();