Get only WP L-1

This commit is contained in:
Rodel Calasagsag 2023-09-03 10:29:42 +08:00
parent f493e921d5
commit 6af2632f5f
2 changed files with 604 additions and 667 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,8 @@
const axios = require( 'axios' ).default;
const getVersionWPLatestMinusOne = async ( { core, github } ) => {
const URL_WP_STABLE_VERSION_CHECK =
'https://api.wordpress.org/core/stable-check/1.0/';
const getPreviousTwoVersions = async () => {
const response = await axios
.get( 'http://api.wordpress.org/core/stable-check/1.0/' )
.catch( ( error ) => {
console.log( error.toJSON() );
throw new Error( error.message );
} );
const response = await github.request( URL_WP_STABLE_VERSION_CHECK );
const body = response.data;
const allVersions = Object.keys( body );
@ -22,34 +18,7 @@ const getPreviousTwoVersions = async () => {
( version ) => ! version.startsWith( latestMajorAndMinorNumbers )
);
const latestMinus1MajorAndMinorNumbers = latestMinus1.match(
/^\d+.\d+/
)[ 0 ];
const latestMinus2 = previousStableVersions.find(
( version ) =>
! (
version.startsWith( latestMajorAndMinorNumbers ) ||
version.startsWith( latestMinus1MajorAndMinorNumbers )
)
);
const matrix = {
version: [
{
number: latestMinus1,
description: 'WP Latest-1',
env_description: 'wp-latest-1',
},
{
number: latestMinus2,
description: 'WP Latest-2',
env_description: 'wp-latest-2',
},
],
};
return matrix;
core.setOutput( 'version', latestMinus1 );
};
module.exports = { getPreviousTwoVersions };
module.exports = { getVersionWPLatestMinusOne };