Skip to content
Closed
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: 15 additions & 0 deletions scripts/bump-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* - 0.3.0 -> 0.3.0-preview.1.0
* - 0.3.0-preview.1.0 -> 0.3.0-preview.1.1 (preview)
* - 0.3.0-preview.1.0 -> 0.3.0-preview.2.0 (preview-major)
* - 0.3.0-preview.3 -> 0.3.0-preview.3.1 (preview, single-number compat)
* - 0.3.0-preview.3 -> 0.3.0-preview.4.0 (preview-major, single-number compat)
*/
import { execSync } from 'child_process';
import { existsSync, readFileSync, writeFileSync } from 'fs';
Expand Down Expand Up @@ -70,6 +72,19 @@ function parseVersion(version: string): ParsedVersion {
};
}

// Match single-number preview format: X.Y.Z-preview.N (e.g., 0.3.0-preview.3)
// Treat as preview.N.0 for compatibility with the two-part format
const singlePreviewMatch = /^(\d+)\.(\d+)\.(\d+)-preview\.(\d+)$/.exec(version);
if (singlePreviewMatch) {
return {
major: parseInt(singlePreviewMatch[1]!, 10),
minor: parseInt(singlePreviewMatch[2]!, 10),
patch: parseInt(singlePreviewMatch[3]!, 10),
previewMajor: parseInt(singlePreviewMatch[4]!, 10),
previewMinor: 0,
};
}

// Match standard versions like: 1.2.3, 1.2.3-beta.1, 1.2.3-rc.0
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z]+)\.(\d+))?$/.exec(version);

Expand Down
Loading