const assert = require('node:assert/strict'); const { execFileSync } = require('node:child_process'); const { version } = require('../package.json'); // eslint-disable-next-line sonarjs/no-os-command-from-path -- Developer-only command uses the operator PATH and fixed executable/arguments; no request input. const git = (...args) => execFileSync('git', args, { encoding: 'utf8' }).trim(); const tags = git('tag', '--merged', 'HEAD', '--list', 'v[0-9]*', '--sort=-version:refname') .split('\n').filter((tag) => /^v\d+\.\d+\.\d+$/.test(tag)); assert.equal(version, tags[0]?.slice(1) ?? '0.0.0', 'Version is already prepared or release tags are missing. Fetch tags; finish the existing release before preparing another.');