Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pre-release version syntax to all relevant tools #1823

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions bin/plugin/commands/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function updateReadmeChangelog( readmeFile, changelog ) {
const fileContent = fs.readFileSync( readmeFile, 'utf-8' );

const stableTagVersionMatches = fileContent.match(
/^Stable tag:\s*(\d+\.\d+\.\d+)$/m
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
);
if ( ! stableTagVersionMatches ) {
throw new Error( `Unable to locate stable tag in ${ readmeFile }` );
Expand Down Expand Up @@ -112,7 +112,7 @@ function getStableTag( readmeFilePath ) {
const readmeContents = fs.readFileSync( readmeFilePath, 'utf-8' );

const stableTagVersionMatches = readmeContents.match(
/^Stable tag:\s*(\d+\.\d+\.\d+)$/m
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
);
if ( ! stableTagVersionMatches ) {
throw new Error( `Unable to locate stable tag in ${ readmeFilePath }` );
Expand Down
2 changes: 1 addition & 1 deletion bin/plugin/commands/since.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports.handler = async ( opt ) => {
const readmeFile = path.resolve( pluginDirectory, 'readme.txt' );
const readmeContent = fs.readFileSync( readmeFile, 'utf-8' );
const readmeContentMatches = readmeContent.match(
/^Stable tag:\s+(\d+\.\d+\.\d+)$/m
/^Stable tag:\s+(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
);
if ( ! readmeContentMatches ) {
throw new Error(
Expand Down
10 changes: 5 additions & 5 deletions bin/plugin/commands/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ async function checkPluginDirectory( pluginDirectory ) {
const readmeContents = fs.readFileSync( readmeFilePath, 'utf-8' );

const stableTagVersionMatches = readmeContents.match(
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-\w+)?)$/m
/^Stable tag:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
);
if ( ! stableTagVersionMatches ) {
throw new Error( `Unable to locate stable tag in ${ readmeFilePath }` );
}
const stableTagVersion = stableTagVersionMatches[ 1 ];

const latestChangelogMatches = readmeContents.match(
/^== Changelog ==\n+= (\d+\.\d+\.\d+(?:-\w+)?) =$/m
/^== Changelog ==\n+= (\d+\.\d+\.\d+(?:-[\w\.]+)?) =$/m
);
if ( ! latestChangelogMatches ) {
throw new Error(
'Unable to latest version entry in readme changelog.'
'Unable to locate latest version entry in readme changelog.'
);
}
const latestChangelogVersion = latestChangelogMatches[ 1 ];
Expand All @@ -71,7 +71,7 @@ async function checkPluginDirectory( pluginDirectory ) {
}

const headerVersionMatches = phpBootstrapFileContents.match(
/^ \* Version:\s+(\d+\.\d+\.\d+(?:-\w+)?)$/m
/^ \* Version:\s+(\d+\.\d+\.\d+(?:-[\w\.]+)?)$/m
);
if ( ! headerVersionMatches ) {
throw new Error(
Expand All @@ -81,7 +81,7 @@ async function checkPluginDirectory( pluginDirectory ) {
const headerVersion = headerVersionMatches[ 1 ];

const phpLiteralVersionMatches = phpBootstrapFileContents.match(
/'(\d+\.\d+\.\d+(?:-\w+)?)'/
/'(\d+\.\d+\.\d+(?:-[\w\.]+)?)'/
);
if ( ! phpLiteralVersionMatches ) {
throw new Error( 'Unable to locate the PHP literal version.' );
Expand Down
2 changes: 1 addition & 1 deletion tools/webpack/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getPluginVersion = ( pluginPath ) => {
const readmePath = path.resolve( pluginPath, 'readme.txt' );

const fileContent = fs.readFileSync( readmePath, 'utf-8' );
const versionRegex = /(?:Stable tag|v)\s*:\s*(\d+\.\d+\.\d+)/i;
const versionRegex = /(?:Stable tag|v)\s*:\s*(\d+\.\d+\.\d+(?:-[\w\.]+)?)/i;
const match = versionRegex.exec( fileContent );

if ( match ) {
Expand Down
Loading