Code Freeze CLI: Replace PHP script with TS (#38233)
This commit is contained in:
parent
06006619b3
commit
e860e1f21f
|
@ -8686,9 +8686,9 @@ packages:
|
||||||
'@babel/core': 7.21.3
|
'@babel/core': 7.21.3
|
||||||
'@babel/helper-annotate-as-pure': 7.16.7
|
'@babel/helper-annotate-as-pure': 7.16.7
|
||||||
'@babel/helper-module-imports': 7.16.7
|
'@babel/helper-module-imports': 7.16.7
|
||||||
'@babel/helper-plugin-utils': 7.20.2
|
'@babel/helper-plugin-utils': 7.18.9
|
||||||
'@babel/plugin-syntax-jsx': 7.16.7(@babel/core@7.21.3)
|
'@babel/plugin-syntax-jsx': 7.16.7(@babel/core@7.21.3)
|
||||||
'@babel/types': 7.21.3
|
'@babel/types': 7.17.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@babel/plugin-transform-react-jsx@7.19.0(@babel/core@7.12.9):
|
/@babel/plugin-transform-react-jsx@7.19.0(@babel/core@7.12.9):
|
||||||
|
@ -20812,8 +20812,8 @@ packages:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
postcss: ^8.1.0
|
postcss: ^8.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
browserslist: 4.21.4
|
browserslist: 4.20.2
|
||||||
caniuse-lite: 1.0.30001418
|
caniuse-lite: 1.0.30001352
|
||||||
fraction.js: 4.2.0
|
fraction.js: 4.2.0
|
||||||
normalize-range: 0.1.2
|
normalize-range: 0.1.2
|
||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
|
@ -22356,7 +22356,6 @@ packages:
|
||||||
escalade: 3.1.1
|
escalade: 3.1.1
|
||||||
node-releases: 2.0.6
|
node-releases: 2.0.6
|
||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/browserslist@4.20.4:
|
/browserslist@4.20.4:
|
||||||
resolution: {integrity: sha512-ok1d+1WpnU24XYN7oC3QWgTyMhY/avPJ/r9T00xxvUOIparA/gc+UPUMaod3i+G6s+nI2nUb9xZ5k794uIwShw==}
|
resolution: {integrity: sha512-ok1d+1WpnU24XYN7oC3QWgTyMhY/avPJ/r9T00xxvUOIparA/gc+UPUMaod3i+G6s+nI2nUb9xZ5k794uIwShw==}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { updateTrunkChangelog, updateReleaseBranchChangelogs } from './lib';
|
||||||
import { Options } from './types';
|
import { Options } from './types';
|
||||||
|
|
||||||
export const changelogCommand = new Command( 'changelog' )
|
export const changelogCommand = new Command( 'changelog' )
|
||||||
.description( 'Create a new release branch' )
|
.description( 'Make changelog pull requests to trunk and release branch' )
|
||||||
.option(
|
.option(
|
||||||
'-o --owner <owner>',
|
'-o --owner <owner>',
|
||||||
'Repository owner. Default: woocommerce',
|
'Repository owner. Default: woocommerce',
|
||||||
|
@ -28,6 +28,11 @@ export const changelogCommand = new Command( 'changelog' )
|
||||||
'-d --dev-repo-path <devRepoPath>',
|
'-d --dev-repo-path <devRepoPath>',
|
||||||
'Path to existing repo. Use this option to avoid cloning a fresh repo for development purposes. Note that using this option assumes dependencies are already installed.'
|
'Path to existing repo. Use this option to avoid cloning a fresh repo for development purposes. Note that using this option assumes dependencies are already installed.'
|
||||||
)
|
)
|
||||||
|
.option(
|
||||||
|
'-o, --override <override>',
|
||||||
|
"Time Override: The time to use in checking whether the action should run (default: 'now').",
|
||||||
|
'now'
|
||||||
|
)
|
||||||
.requiredOption( '-v, --version <version>', 'Version to bump to' )
|
.requiredOption( '-v, --version <version>', 'Version to bump to' )
|
||||||
.action( async ( options: Options ) => {
|
.action( async ( options: Options ) => {
|
||||||
const { owner, name, version, devRepoPath } = options;
|
const { owner, name, version, devRepoPath } = options;
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
*/
|
*/
|
||||||
import simpleGit from 'simple-git';
|
import simpleGit from 'simple-git';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
|
import { readFile, writeFile } from 'fs/promises';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -11,6 +13,58 @@ import { Logger } from '../../../../core/logger';
|
||||||
import { checkoutRemoteBranch } from '../../../../core/git';
|
import { checkoutRemoteBranch } from '../../../../core/git';
|
||||||
import { createPullRequest } from '../../../../core/github/repo';
|
import { createPullRequest } from '../../../../core/github/repo';
|
||||||
import { Options } from '../types';
|
import { Options } from '../types';
|
||||||
|
import { getToday } from '../../verify-day/utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform changelog adjustments after Jetpack Changelogger has run.
|
||||||
|
*
|
||||||
|
* @param {string} override Time override.
|
||||||
|
* @param {string} tmpRepoPath Path where the temporary repo is cloned.
|
||||||
|
*/
|
||||||
|
const updateReleaseChangelogs = async (
|
||||||
|
override: string,
|
||||||
|
tmpRepoPath: string
|
||||||
|
) => {
|
||||||
|
const today = getToday( override );
|
||||||
|
|
||||||
|
// The release date is 22 days after the code freeze.
|
||||||
|
const releaseTime = new Date( today.getTime() + 22 * 24 * 60 * 60 * 1000 );
|
||||||
|
const releaseDate = releaseTime.toISOString().split( 'T' )[ 0 ];
|
||||||
|
|
||||||
|
const readmeFile = path.join(
|
||||||
|
tmpRepoPath,
|
||||||
|
'plugins',
|
||||||
|
'woocommerce',
|
||||||
|
'readme.txt'
|
||||||
|
);
|
||||||
|
const nextLogFile = path.join(
|
||||||
|
tmpRepoPath,
|
||||||
|
'plugins',
|
||||||
|
'woocommerce',
|
||||||
|
'NEXT_CHANGELOG.md'
|
||||||
|
);
|
||||||
|
|
||||||
|
let readme = await readFile( readmeFile, 'utf-8' );
|
||||||
|
let nextLog = await readFile( nextLogFile, 'utf-8' );
|
||||||
|
|
||||||
|
nextLog = nextLog.replace(
|
||||||
|
/= (\d+\.\d+\.\d+) YYYY-mm-dd =/,
|
||||||
|
`= $1 ${ releaseDate } =`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Convert PR number to markdown link.
|
||||||
|
nextLog = nextLog.replace(
|
||||||
|
/\[#(\d+)\]/g,
|
||||||
|
'[$&](https://github.com/woocommerce/woocommerce/pull/$1)'
|
||||||
|
);
|
||||||
|
|
||||||
|
readme = readme.replace(
|
||||||
|
/== Changelog ==\n(.*?)\[See changelog for all versions\]/s,
|
||||||
|
`== Changelog ==\n\n${ nextLog }\n\n[See changelog for all versions]`
|
||||||
|
);
|
||||||
|
|
||||||
|
await writeFile( readmeFile, readme );
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform changelog operations on release branch by submitting a pull request. The release branch is a remote branch.
|
* Perform changelog operations on release branch by submitting a pull request. The release branch is a remote branch.
|
||||||
|
@ -67,10 +121,7 @@ export const updateReleaseBranchChangelogs = async (
|
||||||
Logger.notice( `git deletion hash: ${ deletionCommitHash }` );
|
Logger.notice( `git deletion hash: ${ deletionCommitHash }` );
|
||||||
|
|
||||||
Logger.notice( `Updating readme.txt in ${ tmpRepoPath }` );
|
Logger.notice( `Updating readme.txt in ${ tmpRepoPath }` );
|
||||||
execSync( 'php .github/workflows/scripts/release-changelog.php', {
|
await updateReleaseChangelogs( options.override, tmpRepoPath );
|
||||||
cwd: tmpRepoPath,
|
|
||||||
stdio: 'inherit',
|
|
||||||
} );
|
|
||||||
|
|
||||||
Logger.notice(
|
Logger.notice(
|
||||||
`Committing readme.txt changes in ${ branch } on ${ tmpRepoPath }`
|
`Committing readme.txt changes in ${ branch } on ${ tmpRepoPath }`
|
||||||
|
|
|
@ -3,4 +3,5 @@ export type Options = {
|
||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
devRepoPath?: string;
|
devRepoPath?: string;
|
||||||
|
override: string;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,8 @@ export const verifyDayCommand = new Command( 'verify-day' )
|
||||||
.description( 'Verify if today is the code freeze day' )
|
.description( 'Verify if today is the code freeze day' )
|
||||||
.option(
|
.option(
|
||||||
'-o, --override <override>',
|
'-o, --override <override>',
|
||||||
"Time Override: The time to use in checking whether the action should run (default: 'now')."
|
"Time Override: The time to use in checking whether the action should run (default: 'now').",
|
||||||
|
'now'
|
||||||
)
|
)
|
||||||
.action( ( { override } ) => {
|
.action( ( { override } ) => {
|
||||||
const today = getToday( override );
|
const today = getToday( override );
|
||||||
|
|
Loading…
Reference in New Issue