Skip to content

Commit c99994d

Browse files
committed
Enable bundle-openapi CLI to process any branch
1 parent c1538cd commit c99994d

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@redpanda-data/docs-extensions-and-macros",
3-
"version": "4.10.5",
3+
"version": "4.10.6",
44
"description": "Antora extensions and macros developed for Redpanda documentation.",
55
"keywords": [
66
"antora",

tools/bundle-openapi.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,15 @@ function normalizeTag(tag) {
2828
throw new Error('Invalid version format: tag cannot be empty');
2929
}
3030

31-
// Handle dev branch
32-
if (tag === 'dev') {
33-
return 'dev';
34-
}
35-
3631
// Remove 'v' prefix if present
3732
const normalized = tag.startsWith('v') ? tag.slice(1) : tag;
38-
3933
// Validate semantic version format
4034
const semverPattern = /^\d+\.\d+\.\d+(-[\w\.-]+)?(\+[\w\.-]+)?$/;
41-
if (!semverPattern.test(normalized) && normalized !== 'dev') {
42-
throw new Error(`Invalid version format: ${tag}. Expected format like v25.1.1 or 25.1.1`);
35+
if (semverPattern.test(normalized)) {
36+
return normalized;
4337
}
44-
45-
return normalized;
38+
// If not a valid semver, treat as branch name and return as-is
39+
return tag;
4640
}
4741

4842
/**
@@ -59,22 +53,20 @@ function getMajorMinor(version) {
5953
throw new Error('Version must be a non-empty string');
6054
}
6155

62-
if (version === 'dev') {
63-
return 'dev';
56+
// Only process if valid semver, else return as-is (branch name)
57+
const semverPattern = /^\d+\.\d+\.\d+(-[\w\.-]+)?(\+[\w\.-]+)?$/;
58+
if (!semverPattern.test(version)) {
59+
return version;
6460
}
65-
6661
const parts = version.split('.');
6762
if (parts.length < 2) {
6863
throw new Error(`Invalid version format: ${version}. Expected X.Y.Z format`);
6964
}
70-
7165
const major = parseInt(parts[0], 10);
7266
const minor = parseInt(parts[1], 10);
73-
7467
if (isNaN(major) || isNaN(minor)) {
7568
throw new Error(`Major and minor versions must be numbers: ${version}`);
7669
}
77-
7870
return `${major}.${minor}`;
7971
}
8072

0 commit comments

Comments
 (0)