Skip to content
Merged
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
15 changes: 11 additions & 4 deletions scripts/generate-merge-commit-message.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/usr/bin/env node

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');

try {
// Get the current version of @teambit/bit from npm
const version = execSync('npm show @teambit/bit version', { encoding: 'utf8' }).trim();
// Read the version of teambit.harmony/bit from .bitmap - at commit time it already
// holds the version that was just tagged (and published to npm) by `bit ci merge`.
// Querying npm here instead is racy: the registry read endpoints may lag the publish
// by seconds to minutes, which used to produce commit messages one release behind.
const bitmapRaw = fs.readFileSync(path.join(__dirname, '..', '.bitmap'), 'utf8');
const bitmapJson = bitmapRaw.replace(/\/\*[\s\S]*?\*\//g, '');
const bitmap = JSON.parse(bitmapJson);
const version = bitmap.bit.version;
if (!version) throw new Error('bit entry has no version');

// Generate the commit message with the version
console.log(`bump teambit version to ${version} [skip ci]`);
} catch {
// Fallback to default message if version lookup fails
Expand Down
Loading