Commit c064ccee5af for woocommerce
commit c064ccee5af366dc02a85c002b12b0f659ab3993
Author: Brian Coords <bacoords@gmail.com>
Date: Mon Oct 5 08:31:11 2026 -0700
Remove obsolete release post publishing tools (#69304)
* Remove obsolete release post publishing tools
* Keep release-posts name for contributor tooling
* Flatten nested release refs in contributor filenames
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fe97588cdc8..284f52348a1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4146,9 +4146,6 @@ importers:
'@woocommerce/monorepo-utils':
specifier: workspace:*
version: link:../monorepo-utils
- code-analyzer:
- specifier: workspace:*
- version: link:../code-analyzer
commander:
specifier: 9.4.0
version: 9.4.0
@@ -4158,24 +4155,9 @@ importers:
ejs:
specifier: ^3.1.9
version: 3.1.10
- enquirer:
- specifier: ^2.4.1
- version: 2.4.1
- express:
- specifier: ^4.18.2
- version: 4.22.1
- form-data:
- specifier: ^4.0.6
- version: 4.0.6
lodash.shuffle:
specifier: ^4.2.0
version: 4.2.0
- node-fetch:
- specifier: ^2.7.0
- version: 2.7.0(encoding@0.1.13)
- open:
- specifier: ^8.4.2
- version: 8.4.2
semver:
specifier: ^7.5.4
version: 7.7.4
@@ -4189,18 +4171,12 @@ importers:
'@types/ejs':
specifier: ^3.1.5
version: 3.1.5
- '@types/express':
- specifier: ^4.17.21
- version: 4.17.25
'@types/lodash.shuffle':
specifier: ^4.2.9
version: 4.2.9
'@types/node':
specifier: ^24.1.0
version: 24.12.2
- '@types/node-fetch':
- specifier: ^2.6.9
- version: 2.6.13
'@types/semver':
specifier: ^7.5.6
version: 7.7.1
diff --git a/tools/release-posts/.env.sample b/tools/release-posts/.env.sample
index eb117c2f3cf..493d83615de 100644
--- a/tools/release-posts/.env.sample
+++ b/tools/release-posts/.env.sample
@@ -1,9 +1 @@
-GITHUB_ACCESS_TOKEN="yourtokengoeshere"
-WPCOM_OAUTH_CLIENT_ID="client ID for an oauth app you created on WP.com"
-WPCOM_OAUTH_CLIENT_SECRET="client secret for an oauth app you created on WP.com"
-# optional - override if you need the redirect handler to run on a different port or path
-WPCOM_OAUTH_REDIRECT_URI="http://localhost:3000/oauth"
-
-# levels: error, warn, silent
-LOGGER_LEVEL="warn"
-
+GITHUB_ACCESS_TOKEN="your GitHub token"
diff --git a/tools/release-posts/README.md b/tools/release-posts/README.md
index f6a578c13a0..f4fe549847e 100644
--- a/tools/release-posts/README.md
+++ b/tools/release-posts/README.md
@@ -1,49 +1,18 @@
-# Release Post Generator CLI tool
+# Release post tools
-This is a cli tool designed to generate draft release posts for WooCommerce.
-Posts generated via the tool will be draft posted to <https://developer.woocommerce.com>.
-
-You can also generate an HTML representation of the post if you
-don't have access to a WordPress.com auth token.
+This package currently generates an HTML list of contributors between two WooCommerce release refs. The [release commits and contributors workflow](../../.github/workflows/release-commits-and-contributors.yml) uploads the list as an artifact for the release team.
## Setup
-1. Make sure `pnpm i` has been run in the monorepo.
-2. Make sure you have added a `.env` file with the env variables set. WCCOM_TOKEN is optional if you're using `--outputOnly`, but
- the `GITHUB_ACCESS_TOKEN` is required. If you need help generating a token see [the docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). To silence all CLI output, set `LOGGER_LEVEL` to `"silent"`.
-3. Note that the env file should live at the same path that you're running the command from.
-4. Run the tool via the npm script, e.g. `pnpm release-post release "6.8.0" --outputOnly`
-5. For more help on individual options, run the help `pnpm release-post <command> --help`. e.g. `pnpm release-post rc --help`
-
-## Publishing Draft Posts
-
-This tool will publish draft posts to `https://developer.woocommerce.com` for you if you omit the `--outputOnly` flag. There is some minimal first time setup for this though:
-
-1. Create an app on WordPress.com [here](https://developer.wordpress.com/apps/).
-2. Recommended settings:
- - Name can be anything
- - Description can be left blank
- - Website URL just put `http://localhost`
- - Redirect URLs, by default you should add: `http://localhost:3000/oauth`
- - JavaScript Origins put `http://localhost`
- - Type - choose "Web"
-3. Once your app is created you can go back to the
- app list and click "manage app".
-4. Take note of the `client secret` and the `client id`.
-5. In your `.env` file add the client secret to the `WPCOM_OAUTH_CLIENT_SECRET` variable and the client id to the `WPCOM_OAUTH_CLIENT_ID` variable.
-
-## Generating Just a Contributors List
-
-If you don't have a final release yet you can generate an HTML contributors list that you can copy
-paste into a blank post.
-
-To do that simply run `pnpm release-post contributors "<currentVersion>" "<previousVersion>"`
+1. Run `pnpm install` from the monorepo root.
+2. Set `GITHUB_ACCESS_TOKEN` to a GitHub token that can read the compared repositories. For local use, copy `.env.sample` to `.env` in this directory and set the token, or export it in the shell.
-## Advanced
+## Generate a list
-If you can't run anything on your localhost port 3000 you may want to override the redirect uri for oauth.
+Run this from `tools/release-posts`:
-Steps:
+```bash
+pnpm release-post contributors release/11.0 release/10.9
+```
-1. Add your preferred redirect URI to the `WPCOM_OAUTH_REDIRECT_URI` variable in `.env`. e.g. `http://localhost:4321/oauth`
-2. When creating your app on [WordPress.com](https://developer.wordpress.com/apps/) make sure the redirect URL you set matches the one set in `.env`
+The command prints the path to the generated HTML file in the system temporary directory. It reads the WooCommerce and Action Scheduler release changes from GitHub; it does not publish a post.
diff --git a/tools/release-posts/commands/release-post/index.ts b/tools/release-posts/commands/release-post/index.ts
deleted file mode 100644
index 715b7e42ff9..00000000000
--- a/tools/release-posts/commands/release-post/index.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * External dependencies
- */
-import { program } from '@commander-js/extra-typings';
-import dotenv from 'dotenv';
-
-dotenv.config();
-
-program
- .name( 'release-post' )
- .version( '0.0.1' )
- .command( 'release', 'Generate release post', { isDefault: true } )
- .command( 'beta', 'Generate draft beta release post' )
- .command( 'rc', 'Generate draft RC release post' )
- .command(
- 'contributors',
- 'Generate a list of contributors for a release post'
- );
-
-program.parse( process.argv );
diff --git a/tools/release-posts/commands/release-post/release-post-beta.ts b/tools/release-posts/commands/release-post/release-post-beta.ts
deleted file mode 100755
index 50052891d11..00000000000
--- a/tools/release-posts/commands/release-post/release-post-beta.ts
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * External dependencies
- */
-import semver from 'semver';
-import { writeFile } from 'fs/promises';
-import { tmpdir } from 'os';
-import { join } from 'path';
-import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
-import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
-import { Command } from '@commander-js/extra-typings';
-import dotenv from 'dotenv';
-// @ts-expect-error - The enquirer types are incorrect.
-import { Select } from 'enquirer';
-
-/**
- * Internal dependencies
- */
-import { renderTemplate } from '../../lib/render-template';
-import { getWordpressComAuthToken } from '../../lib/oauth-helper';
-import { getMostRecentFinal } from '../../lib/github-api';
-import {
- getFirstTuesdayOfTheMonth,
- getSecondTuesdayOfTheMonth,
-} from '../../lib/dates';
-import {
- createWpComDraftPost,
- searchForPostsByCategory,
-} from '../../lib/draft-post';
-
-const DEVELOPER_WOOCOMMERCE_SITE_ID = '96396764';
-
-dotenv.config();
-
-// Define the release post command
-const program = new Command()
- .command( 'beta' )
- .description( 'CLI to automate generation of a draft beta release post.' )
- .argument(
- '<releaseVersion>',
- 'The version for this post in x.y.z-beta.n format. Ex: 7.1.0-beta.1'
- )
- .option(
- '--releaseDate <date>',
- 'The date for the final release as mm-dd-yyyy, year inferred as current year, defaults to second tuesday of next month.',
- getSecondTuesdayOfTheMonth(
- new Date().getMonth() + 1
- ).toLocaleDateString( 'en-US', {
- month: '2-digit',
- day: '2-digit',
- year: 'numeric',
- } )
- )
- .option(
- '--outputOnly',
- 'Only output the post as HTML, do not publish a draft.'
- )
- .option(
- '--tags <tags>',
- 'Comma separated list of tags to add to the post.',
- 'Releases,WooCommerce Core'
- )
- .option(
- '--siteId <siteId>',
- 'For posting to a non-default site (for testing)'
- )
- .action( async ( releaseVersion, options ) => {
- const {
- outputOnly,
- siteId = DEVELOPER_WOOCOMMERCE_SITE_ID,
- tags,
- releaseDate,
- } = options;
-
- const postTags = ( tags &&
- tags.split( ',' ).map( ( tag ) => tag.trim() ) ) || [
- 'WooCommerce Core',
- 'Releases',
- ];
-
- const finalReleaseDate = new Date( releaseDate );
- const isOutputOnly = !! outputOnly;
- const semverVersion = semver.parse( releaseVersion );
-
- // This is supposed to be a beta post so throw if the version provided is not a beta version.
- // Things we don't accept:
- // * missing beta.x
- // * any other kind of prerelease, e.g. rc
- // * .x must be a number, so not: beta.1b or beta.1.1 but beta.1 is ok.
- if (
- ! semverVersion ||
- ! semverVersion.prerelease.length ||
- typeof semverVersion.prerelease[ 1 ] === 'string' ||
- semverVersion.prerelease[ 0 ] !== 'beta'
- ) {
- throw new Error(
- `Invalid current version: ${ releaseVersion }. Provide current version in x.y.z-beta.n format.`
- );
- } else {
- const [ , prereleaseVersion ] = semverVersion.prerelease;
-
- // Now infer the previous version, if the one you provide is beta.1 we'll need to find the last major release from
- // Github releases. If what you provided is beta.2 we'll assume previous was beta.1
- const previousVersion =
- prereleaseVersion === 1
- ? ( await getMostRecentFinal() ).tag_name
- : `${ semverVersion.major }.${ semverVersion.minor }.${
- semverVersion.patch
- }-beta.${ prereleaseVersion - 1 }`;
-
- const semverPreviousVersion = semver.parse( previousVersion );
-
- if ( ! semverPreviousVersion ) {
- throw new Error(
- `Could not parse previous version from: ${ previousVersion }`
- );
- }
-
- const clientId = getEnvVar( 'WPCOM_OAUTH_CLIENT_ID', true );
- const clientSecret = getEnvVar( 'WPCOM_OAUTH_CLIENT_SECRET', true );
- const redirectUri =
- getEnvVar( 'WPCOM_OAUTH_REDIRECT_URI' ) ||
- 'http://localhost:3000/oauth';
-
- Logger.startTask(
- 'Getting auth token for WordPress.com (needed to find last beta post).'
- );
- const authToken = await getWordpressComAuthToken(
- clientId,
- clientSecret,
- siteId,
- redirectUri,
- 'posts'
- );
- Logger.endTask();
-
- const versionSearch =
- prereleaseVersion === 1
- ? `WooCommerce ${ semverPreviousVersion.major }.${ semverPreviousVersion.minor }.${ semverPreviousVersion.patch }`
- : `WooCommerce ${ semverPreviousVersion.major }.${ semverPreviousVersion.minor } Beta ${ semverPreviousVersion.prerelease[ 1 ] }`;
-
- Logger.startTask(
- `Finding recent release posts with title: ${ versionSearch }`
- );
-
- const posts =
- ( await searchForPostsByCategory(
- siteId,
- versionSearch,
- 'WooCommerce Core',
- authToken
- ) ) || [];
-
- Logger.endTask();
-
- const prompt = new Select( {
- name: 'Previous post',
- message: 'Choose the previous post to link to:',
- choices: posts.length
- ? posts.map( ( p ) => p.title )
- : [ 'No posts found - generate default link' ],
- } );
-
- const lastReleasePostTitle: string = await prompt.run();
- const lastReleasePost = posts.find(
- ( p ) => p.title === lastReleasePostTitle
- );
-
- if ( ! lastReleasePost ) {
- Logger.warn(
- 'Could not find previous release post, make sure to update the link in the post before publishing.'
- );
- }
-
- if ( ! authToken && ! isOutputOnly ) {
- throw new Error(
- 'Error getting auth token, check your env settings are correct.'
- );
- } else {
- const html = await renderTemplate( 'beta-release.ejs', {
- releaseDate,
- betaNumber: prereleaseVersion,
- version: semverVersion,
- previousVersion: semverPreviousVersion,
- prettyVersion: `${ semverVersion.major }.${ semverVersion.minor }.${ semverVersion.patch } Beta ${ prereleaseVersion }`,
- prettyPreviousVersion: `${ semverPreviousVersion.major }.${
- semverPreviousVersion.minor
- }.${ semverPreviousVersion.patch }${
- semverPreviousVersion.prerelease.length
- ? ' ' +
- semverPreviousVersion.prerelease[ 0 ] +
- ' ' +
- semverPreviousVersion.prerelease[ 1 ]
- : ''
- }`,
- rcReleaseDate: getFirstTuesdayOfTheMonth(
- finalReleaseDate.getMonth()
- ),
- finalReleaseDate,
- lastReleasePostUrl:
- lastReleasePost?.URL ||
- 'https://developer.woocommerce.com/category/release-posts/',
- } );
-
- if ( isOutputOnly ) {
- const tmpFile = join(
- tmpdir(),
- `beta-release-${ releaseVersion }.html`
- );
-
- await writeFile( tmpFile, html );
-
- Logger.notice( `Output written to ${ tmpFile }` );
- } else {
- Logger.startTask( 'Publishing draft release post' );
- const { ID } = await createWpComDraftPost(
- siteId,
- `WooCommerce ${ semverVersion.major }.${ semverVersion.minor } Beta ${ prereleaseVersion } Released`,
- html,
- postTags,
- authToken
- );
- Logger.notice(
- `Release post created, edit it here: \nhttps://wordpress.com/post/developer.woocommerce.com/${ ID }`
- );
- Logger.endTask();
- }
- }
- }
- } );
-
-program.parse( process.argv );
diff --git a/tools/release-posts/commands/release-post/release-post-contributors.ts b/tools/release-posts/commands/release-post/release-post-contributors.ts
deleted file mode 100644
index be5a659d276..00000000000
--- a/tools/release-posts/commands/release-post/release-post-contributors.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * External dependencies
- */
-import { Command } from '@commander-js/extra-typings';
-import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
-import { writeFile } from 'fs/promises';
-import { tmpdir } from 'os';
-import { join } from 'path';
-
-/**
- * Internal dependencies
- */
-import { generateContributors } from '../../lib/contributors';
-import { renderTemplate } from '../../lib/render-template';
-
-// Define the contributors command
-const program = new Command()
- .command( 'contributors' )
- .description( 'CLI to automate generation of a release post.' )
- .argument(
- '<currentVersion>',
- 'The version of the plugin to generate a post for, please use the tag version from Github.'
- )
- .argument(
- '--previousVersion <previousVersion>',
- 'If you would like to compare against a version other than last minor you can provide a tag version from Github.'
- )
- .action( async ( currentVersion, previousVersion ) => {
- Logger.startTask( 'Generating contributors list...' );
-
- const contributors = await generateContributors(
- currentVersion,
- previousVersion.toString()
- );
-
- Logger.endTask();
-
- const html = await renderTemplate( 'contributors.ejs', {
- contributors,
- } );
-
- const tmpFile = join(
- tmpdir(),
- `contributors-${ currentVersion.replace( '/', '-' ) }.html`
- );
-
- await writeFile( tmpFile, html );
-
- Logger.notice( `Contributors HTML generated at ${ tmpFile }` );
- } );
-
-program.parse( process.argv );
diff --git a/tools/release-posts/commands/release-post/release-post-rc.ts b/tools/release-posts/commands/release-post/release-post-rc.ts
deleted file mode 100644
index e74a76dfce7..00000000000
--- a/tools/release-posts/commands/release-post/release-post-rc.ts
+++ /dev/null
@@ -1,225 +0,0 @@
-/**
- * External dependencies
- */
-import semver from 'semver';
-import { writeFile } from 'fs/promises';
-import { tmpdir } from 'os';
-import { join } from 'path';
-import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
-import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
-import { Command } from '@commander-js/extra-typings';
-import dotenv from 'dotenv';
-// @ts-expect-error - The enquirer types are incorrect.
-import { Select } from 'enquirer';
-
-/**
- * Internal dependencies
- */
-import { renderTemplate } from '../../lib/render-template';
-import { getWordpressComAuthToken } from '../../lib/oauth-helper';
-import { getMostRecentBeta } from '../../lib/github-api';
-import { getSecondTuesdayOfTheMonth } from '../../lib/dates';
-import {
- createWpComDraftPost,
- searchForPostsByCategory,
-} from '../../lib/draft-post';
-
-const DEVELOPER_WOOCOMMERCE_SITE_ID = '96396764';
-
-dotenv.config();
-
-// Define the release post command
-const program = new Command()
- .command( 'beta' )
- .description( 'CLI to automate generation of a draft RC release post.' )
- .argument(
- '<releaseVersion>',
- 'The version for this post in x.y.z-rc.n format. Ex: 7.1.0-rc.1'
- )
- .option(
- '--releaseDate <date>',
- 'The date for the final release as mm-dd-yyyy, year inferred as current year, defaults to second tuesday of next month.',
- getSecondTuesdayOfTheMonth(
- new Date().getMonth() + 1
- ).toLocaleDateString( 'en-US', {
- month: '2-digit',
- day: '2-digit',
- year: 'numeric',
- } )
- )
- .option(
- '--outputOnly',
- 'Only output the post as HTML, do not publish a draft.'
- )
- .option(
- '--tags <tags>',
- 'Comma separated list of tags to add to the post.',
- 'Releases,WooCommerce Core'
- )
- .option(
- '--siteId <siteId>',
- 'For posting to a non-default site (for testing)'
- )
- .action( async ( releaseVersion, options ) => {
- const {
- outputOnly,
- siteId = DEVELOPER_WOOCOMMERCE_SITE_ID,
- tags,
- releaseDate,
- } = options;
-
- const postTags = ( tags &&
- tags.split( ',' ).map( ( tag ) => tag.trim() ) ) || [
- 'WooCommerce Core',
- 'Releases',
- ];
-
- const finalReleaseDate = new Date( releaseDate );
- const isOutputOnly = !! outputOnly;
- const semverVersion = semver.parse( releaseVersion );
-
- // This is supposed to be a RC post so throw if the version provided is not an RC version.
- // Things we don't accept:
- // * missing rc.x
- // * any other kind of prerelease, e.g. beta
- // * .x must be a number, so not: rc.1b or rc.1.1 but rc.1 is ok.
- if (
- ! semverVersion ||
- ! semverVersion.prerelease.length ||
- typeof semverVersion.prerelease[ 1 ] === 'string' ||
- semverVersion.prerelease[ 0 ] !== 'rc'
- ) {
- throw new Error(
- `Invalid current version: ${ releaseVersion }. Provide current version in x.y.z-rc.n format.`
- );
- } else {
- const [ , prereleaseVersion ] = semverVersion.prerelease;
-
- // Now infer the previous version, if the one you provide is rc.1 we'll need to find the last beta release from
- // Github releases. If what you provided is rc.2 we'll assume previous was rc.1
- const previousVersion =
- prereleaseVersion === 1
- ? ( await getMostRecentBeta() ).tag_name
- : `${ semverVersion.major }.${ semverVersion.minor }.${
- semverVersion.patch
- }-rc.${ prereleaseVersion - 1 }`;
-
- const semverPreviousVersion = semver.parse( previousVersion );
-
- if ( ! semverPreviousVersion ) {
- throw new Error(
- `Could not parse previous version from: ${ previousVersion }`
- );
- }
-
- const clientId = getEnvVar( 'WPCOM_OAUTH_CLIENT_ID', true );
- const clientSecret = getEnvVar( 'WPCOM_OAUTH_CLIENT_SECRET', true );
- const redirectUri =
- getEnvVar( 'WPCOM_OAUTH_REDIRECT_URI' ) ||
- 'http://localhost:3000/oauth';
-
- Logger.startTask(
- 'Getting auth token for WordPress.com (needed to find last RC post).'
- );
- const authToken = await getWordpressComAuthToken(
- clientId,
- clientSecret,
- siteId,
- redirectUri,
- 'posts'
- );
- Logger.endTask();
-
- const versionSearch =
- prereleaseVersion === 1
- ? `WooCommerce ${ semverPreviousVersion.major }.${ semverPreviousVersion.minor }.${ semverPreviousVersion.patch } Beta`
- : `WooCommerce ${ semverPreviousVersion.major }.${ semverPreviousVersion.minor } Release Candidate`;
-
- Logger.startTask(
- `Finding recent release posts with title: ${ versionSearch }`
- );
-
- const posts =
- ( await searchForPostsByCategory(
- siteId,
- versionSearch,
- 'WooCommerce Core',
- authToken
- ) ) || [];
-
- Logger.endTask();
-
- const prompt = new Select( {
- name: 'Previous post',
- message: 'Choose the previous post to link to:',
- choices: posts.length
- ? posts.map( ( p ) => p.title )
- : [ 'No posts found - generate default link' ],
- } );
-
- const lastReleasePostTitle: string = await prompt.run();
- const lastReleasePost = posts.find(
- ( p ) => p.title === lastReleasePostTitle
- );
-
- if ( ! lastReleasePost ) {
- Logger.warn(
- 'Could not find previous release post, make sure to update the link in the post before publishing.'
- );
- }
-
- if ( ! authToken && ! isOutputOnly ) {
- throw new Error(
- 'Error getting auth token, check your env settings are correct.'
- );
- } else {
- const html = await renderTemplate( 'rc-release.ejs', {
- releaseDate,
- rcNumber: prereleaseVersion,
- version: semverVersion,
- previousVersion: semverPreviousVersion,
- prettyVersion: `${ semverVersion.major }.${ semverVersion.minor }.${ semverVersion.patch } RC ${ prereleaseVersion }`,
- prettyPreviousVersion: `${ semverPreviousVersion.major }.${
- semverPreviousVersion.minor
- }.${ semverPreviousVersion.patch }${
- semverPreviousVersion.prerelease.length
- ? ' ' +
- semverPreviousVersion.prerelease[ 0 ] +
- ' ' +
- semverPreviousVersion.prerelease[ 1 ]
- : ''
- }`,
- finalReleaseDate,
- lastReleasePostUrl:
- lastReleasePost?.URL ||
- 'https://developer.woocommerce.com/category/release-posts/',
- } );
-
- if ( isOutputOnly ) {
- const tmpFile = join(
- tmpdir(),
- `rc-release-${ releaseVersion }.html`
- );
-
- await writeFile( tmpFile, html );
-
- Logger.notice( `Output written to ${ tmpFile }` );
- } else {
- Logger.startTask( 'Publishing draft release post' );
- const { ID } = await createWpComDraftPost(
- siteId,
- `WooCommerce ${ semverVersion.major }.${ semverVersion.minor } Release Candidate ${ prereleaseVersion }`,
- html,
- postTags,
- authToken
- );
- Logger.notice(
- `Release post created, edit it here: \nhttps://wordpress.com/post/developer.woocommerce.com/${ ID }`
- );
- Logger.endTask();
- }
- }
- }
- } );
-
-program.parse( process.argv );
diff --git a/tools/release-posts/commands/release-post/release-post-release.ts b/tools/release-posts/commands/release-post/release-post-release.ts
deleted file mode 100644
index 8d69d406cff..00000000000
--- a/tools/release-posts/commands/release-post/release-post-release.ts
+++ /dev/null
@@ -1,258 +0,0 @@
-/**
- * External dependencies
- */
-import { scanForChanges } from 'code-analyzer/src/lib/scan-changes';
-import semver from 'semver';
-import { writeFile } from 'fs/promises';
-import { tmpdir } from 'os';
-import { join } from 'path';
-import {
- cloneRepo,
- getCommitHash,
-} from '@woocommerce/monorepo-utils/src/core/git';
-import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
-import { getEnvVar } from '@woocommerce/monorepo-utils/src/core/environment';
-import { Command } from '@commander-js/extra-typings';
-import dotenv from 'dotenv';
-
-/**
- * Internal dependencies
- */
-import { renderTemplate } from '../../lib/render-template';
-import {
- createWpComDraftPost,
- fetchWpComPost,
- editWpComPostContent,
-} from '../../lib/draft-post';
-import { getWordpressComAuthToken } from '../../lib/oauth-helper';
-import { generateContributors } from '../../lib/contributors';
-import { editPostHTML } from '../../lib/edit-post';
-
-const DEVELOPER_WOOCOMMERCE_SITE_ID = '96396764';
-
-const SOURCE_REPO = 'https://github.com/woocommerce/woocommerce.git';
-
-const VERSION_VALIDATION_REGEX =
- /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/;
-
-dotenv.config();
-
-// Define the release post command
-const program = new Command()
- .command( 'release' )
- .description( 'CLI to automate generation of a release post.' )
- .argument(
- '<currentVersion>',
- 'The current version in x.y.z or x.y.z-stage.n format. Ex: 7.1.0, 7.1.0-rc.1'
- )
- .argument(
- '<previousVersion>',
- 'The previous version in x.y.z format. Ex: 7.0.0'
- )
- .option( '--outputOnly', 'Only output the post, do not publish it' )
- .option( '--editPostId <postId>', 'Updates an existing post' )
- .option(
- '--tags <tags>',
- 'Comma separated list of tags to add to the post.',
- 'Releases,WooCommerce Core'
- )
- .option(
- '--siteId <siteId>',
- 'For posting to a non-default site (for testing)'
- )
- .action( async ( currentVersion, previousVersion, options ) => {
- const siteId = options.siteId || DEVELOPER_WOOCOMMERCE_SITE_ID;
- const tags = ( options.tags &&
- options.tags.split( ',' ).map( ( tag ) => tag.trim() ) ) || [
- 'WooCommerce Core',
- 'Releases',
- ];
- const isOutputOnly = !! options.outputOnly;
-
- if ( ! VERSION_VALIDATION_REGEX.test( currentVersion ) ) {
- throw new Error(
- `Invalid current version: ${ currentVersion }. Provide current version in x.y.z or x.y.z-stage.n format.`
- );
- }
-
- if ( ! VERSION_VALIDATION_REGEX.test( previousVersion ) ) {
- throw new Error(
- `Invalid previous version: ${ previousVersion }. Provide previous version in x.y.z format.`
- );
- }
-
- const clientId = getEnvVar( 'WPCOM_OAUTH_CLIENT_ID', true );
- const clientSecret = getEnvVar( 'WPCOM_OAUTH_CLIENT_SECRET', true );
- const redirectUri =
- getEnvVar( 'WPCOM_OAUTH_REDIRECT_URI' ) ||
- 'http://localhost:3000/oauth';
- const authToken =
- isOutputOnly ||
- ( await getWordpressComAuthToken(
- clientId,
- clientSecret,
- siteId,
- redirectUri,
- 'posts'
- ) );
-
- if ( ! authToken ) {
- throw new Error(
- 'Error getting auth token, check your env settings are correct.'
- );
- }
-
- Logger.startTask( `Making temporary clone of ${ SOURCE_REPO }...` );
- const currentParsed = semver.parse( currentVersion );
- const previousParsed = semver.parse( previousVersion );
- const tmpRepoPath = await cloneRepo( SOURCE_REPO );
- Logger.endTask();
- let currentBranch;
- let previousBranch;
- let currentVersionRef;
- let previousVersionRef;
-
- try {
- if ( ! currentParsed ) {
- throw new Error( 'Unable to parse current version' );
- }
- currentBranch = `release/${ currentParsed.major }.${ currentParsed.minor }`;
- currentVersionRef = await getCommitHash(
- tmpRepoPath,
- `remotes/origin/${ currentBranch }`
- );
- } catch ( error: unknown ) {
- Logger.notice(
- `Unable to find '${ currentBranch }', using 'trunk'.`
- );
- currentBranch = 'trunk';
- currentVersionRef = await getCommitHash(
- tmpRepoPath,
- 'remotes/origin/trunk'
- );
- }
-
- try {
- if ( ! previousParsed ) {
- throw new Error( 'Unable to parse previous version' );
- }
- previousBranch = `release/${ previousParsed.major }.${ previousParsed.minor }`;
- previousVersionRef = await getCommitHash(
- tmpRepoPath,
- `remotes/origin/${ previousBranch }`
- );
- } catch ( error: unknown ) {
- throw new Error(
- `Unable to find '${ previousBranch }'. Branch for previous version must exist.`
- );
- }
-
- Logger.notice(
- `Using ${ currentBranch }(${ currentVersionRef }) for current and ${ previousBranch }(${ previousVersionRef }) for previous.`
- );
-
- let postContent;
-
- if ( typeof options.editPostId !== 'undefined' ) {
- try {
- const prevPost = await fetchWpComPost(
- siteId,
- options.editPostId,
- authToken
- );
- postContent = prevPost.content;
- } catch ( error: unknown ) {
- throw new Error(
- `Unable to fetch existing post with ID: ${ options.editPostId }`
- );
- }
- }
-
- const changes = await scanForChanges(
- currentVersionRef,
- `${ previousParsed.major }.${ previousParsed.minor }.${ previousParsed.patch }`,
- SOURCE_REPO,
- previousVersionRef,
- 'cli',
- tmpRepoPath
- );
-
- Logger.startTask( 'Finding contributors' );
- const title = `WooCommerce ${ currentVersion } Released`;
-
- const contributors = await generateContributors(
- currentVersion,
- previousVersion.toString()
- );
-
- const postVariables = {
- contributors,
- title,
- changes,
- displayVersion: currentVersion,
- };
-
- const html =
- typeof options.editPostId !== 'undefined'
- ? editPostHTML( postContent, {
- hooks: await renderTemplate(
- 'hooks.ejs',
- postVariables
- ),
- database: await renderTemplate(
- 'database.ejs',
- postVariables
- ),
- templates: await renderTemplate(
- 'templates.ejs',
- postVariables
- ),
- contributors: await renderTemplate(
- 'contributors.ejs',
- postVariables
- ),
- } )
- : await renderTemplate( 'release.ejs', postVariables );
-
- Logger.endTask();
-
- if ( isOutputOnly ) {
- const tmpFile = join(
- tmpdir(),
- `release-${ currentVersion }.html`
- );
-
- await writeFile( tmpFile, html );
-
- Logger.notice( `Output written to ${ tmpFile }` );
- } else {
- Logger.startTask( 'Publishing draft release post' );
-
- try {
- const { URL } =
- typeof options.editPostId !== 'undefined'
- ? await editWpComPostContent(
- siteId,
- options.editPostId,
- html,
- authToken
- )
- : await createWpComDraftPost(
- siteId,
- title,
- html,
- tags,
- authToken
- );
-
- Logger.notice( `Published draft release post at ${ URL }` );
- Logger.endTask();
- } catch ( error: unknown ) {
- if ( error instanceof Error ) {
- Logger.error( error.message );
- }
- }
- }
- } );
-
-program.parse( process.argv );
diff --git a/tools/release-posts/index.ts b/tools/release-posts/index.ts
index fdecd578d12..616a038bee1 100644
--- a/tools/release-posts/index.ts
+++ b/tools/release-posts/index.ts
@@ -1,16 +1,54 @@
/**
* External dependencies
*/
+import { Command } from '@commander-js/extra-typings';
+import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
import dotenv from 'dotenv';
+import { writeFile } from 'fs/promises';
+import { tmpdir } from 'os';
+import { join } from 'path';
/**
* Internal dependencies
*/
-import { program } from './program';
-import './commands/release-post';
+import { generateContributors } from './lib/contributors';
+import { renderTemplate } from './lib/render-template';
-// Bootstrap environment variables.
dotenv.config();
-// Start the program
+const program = new Command()
+ .name( 'release-post' )
+ .description( 'Utilities for WooCommerce release posts.' );
+
+program
+ .command( 'contributors' )
+ .description(
+ 'Generate an HTML contributors list for a WooCommerce release.'
+ )
+ .argument( '<currentRef>', 'The Git ref for the current release.' )
+ .argument( '<previousRef>', 'The Git ref for the previous release.' )
+ .action( async ( currentRef, previousRef ) => {
+ Logger.startTask( 'Generating contributors list...' );
+
+ const contributors = await generateContributors(
+ currentRef,
+ previousRef
+ );
+
+ Logger.endTask();
+
+ const html = await renderTemplate( 'contributors.ejs', {
+ contributors,
+ } );
+
+ const tmpFile = join(
+ tmpdir(),
+ `contributors-${ currentRef.replaceAll( '/', '-' ) }.html`
+ );
+
+ await writeFile( tmpFile, html );
+
+ Logger.notice( `Contributors HTML generated at ${ tmpFile }` );
+ } );
+
program.parse( process.argv );
diff --git a/tools/release-posts/lib/contributors.ts b/tools/release-posts/lib/contributors.ts
index 263787f2736..0673e405b9e 100644
--- a/tools/release-posts/lib/contributors.ts
+++ b/tools/release-posts/lib/contributors.ts
@@ -43,7 +43,7 @@ export const generateContributors = async (
)
);
- await checkoutRef( repoPath, previousVersion.toString() );
+ await checkoutRef( repoPath, previousVersion );
const previousComposer = JSON.parse(
await readFile(
@@ -84,8 +84,6 @@ export const generateContributors = async (
return {
'WooCommerce Core': coreContributors,
- ActionScheduler: dependencyContributors.ActionScheduler || [],
- 'WooCommerce Blocks':
- dependencyContributors[ 'WooCommerce Blocks' ] || [],
+ ...dependencyContributors,
};
};
diff --git a/tools/release-posts/lib/dates.ts b/tools/release-posts/lib/dates.ts
deleted file mode 100644
index 80d55766e09..00000000000
--- a/tools/release-posts/lib/dates.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-export const getFirstTuesdayOfTheMonth = ( month: number ): Date => {
- // create a new Date object for the first day of the month
- const firstDayOfMonth = new Date( new Date().getFullYear(), month, 1 );
-
- // create a new Date object for the first Tuesday of the month
- const firstTuesday = new Date( firstDayOfMonth );
-
- firstTuesday.setDate( 1 + ( ( 2 - firstDayOfMonth.getDay() + 7 ) % 7 ) );
-
- return firstTuesday;
-};
-
-export const getSecondTuesdayOfTheMonth = ( month: number ): Date => {
- // create a new Date object for the first Tuesday of the month
- const firstTuesday = getFirstTuesdayOfTheMonth( month );
-
- // create a new Date object for the second Tuesday of the current month
- const secondTuesday = new Date( firstTuesday );
- secondTuesday.setDate( secondTuesday.getDate() + 7 );
-
- return secondTuesday;
-};
diff --git a/tools/release-posts/lib/draft-post.ts b/tools/release-posts/lib/draft-post.ts
deleted file mode 100644
index 90116504af3..00000000000
--- a/tools/release-posts/lib/draft-post.ts
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * External dependencies
- */
-import fetch from 'node-fetch';
-import { Logger } from '@woocommerce/monorepo-utils/src/core/logger';
-
-// Typing just the things we need from the WP.com Post object.
-// (which is not the same as WP Post object or API Post object).
-// See example response here: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/ to add more props.
-type WordpressComPost = {
- title: string;
- URL: string;
-};
-
-/**
- * Fetch a post from WordPress.com
- *
- * @param {string} siteId - The site to fetch from.
- * @param {string} postId - The id of the post to fetch.
- * @param {string} authToken - WordPress.com auth token.
- * @return {Promise} - A promise that resolves to the JSON API response.
- */
-export const fetchWpComPost = async (
- siteId: string,
- postId: string,
- authToken: string
-) => {
- try {
- const post = await fetch(
- `https://public-api.wordpress.com/rest/v1.1/sites/${ siteId }/posts/${ postId }`,
- {
- headers: {
- Authorization: `Bearer ${ authToken }`,
- 'Content-Type': 'application/json',
- },
- }
- );
-
- if ( post.status !== 200 ) {
- const text = await post.text();
- throw new Error( `Error creating draft post: ${ text }` );
- }
-
- return post.json();
- } catch ( e: unknown ) {
- if ( e instanceof Error ) {
- Logger.error( e.message );
- }
- }
-};
-
-export const searchForPostsByCategory = async (
- siteId: string,
- search: string,
- category: string,
- authToken: string
-) => {
- try {
- const post = await fetch(
- `https://public-api.wordpress.com/rest/v1.1/sites/${ siteId }/posts?${ new URLSearchParams(
- { search, category }
- ) }`,
- {
- headers: {
- Authorization: `Bearer ${ authToken }`,
- 'Content-Type': 'application/json',
- },
- method: 'GET',
- }
- );
-
- if ( post.status !== 200 ) {
- const text = await post.text();
- throw new Error( `Error creating draft post: ${ text }` );
- }
-
- return ( await post.json() ).posts as WordpressComPost[];
- } catch ( e: unknown ) {
- if ( e instanceof Error ) {
- Logger.error( e.message );
- }
- }
-};
-
-/**
- * Edit a post on wordpress.com
- *
- * @param {string} siteId - The site to post to.
- * @param {string} postId - The post to edit.
- * @param {string} postContent - Post content.
- * @param {string} authToken - WordPress.com auth token.
- * @return {Promise} - A promise that resolves to the JSON API response.
- */
-export const editWpComPostContent = async (
- siteId: string,
- postId: string,
- postContent: string,
- authToken: string
-) => {
- try {
- const post = await fetch(
- `https://public-api.wordpress.com/rest/v1.2/sites/${ siteId }/posts/${ postId }`,
- {
- method: 'POST',
- headers: {
- Authorization: `Bearer ${ authToken }`,
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify( {
- content: postContent,
- } ),
- }
- );
-
- if ( post.status !== 200 ) {
- const text = await post.text();
- throw new Error( `Error creating draft post: ${ text }` );
- }
-
- return post.json();
- } catch ( e: unknown ) {
- if ( e instanceof Error ) {
- Logger.error( e.message );
- }
- }
-};
-
-/**
- * Create a draft of a post on wordpress.com
- *
- * @param {string} siteId - The site to post to.
- * @param {string} postTitle - Post title.
- * @param {string} postContent - Post content.
- * @param {string} authToken - WordPress.com auth token.
- * @return {Promise} - A promise that resolves to the JSON API response.
- */
-export const createWpComDraftPost = async (
- siteId: string,
- postTitle: string,
- postContent: string,
- tags: string[],
- authToken: string
-) => {
- try {
- const post = await fetch(
- `https://public-api.wordpress.com/rest/v1.2/sites/${ siteId }/posts/new`,
- {
- method: 'POST',
- headers: {
- Authorization: `Bearer ${ authToken }`,
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify( {
- title: postTitle,
- content: postContent,
- status: 'draft',
- tags,
- } ),
- }
- );
-
- if ( post.status !== 200 ) {
- const text = await post.text();
- throw new Error( `Error creating draft post: ${ text }` );
- }
-
- return post.json();
- } catch ( e: unknown ) {
- if ( e instanceof Error ) {
- Logger.error( e.message );
- }
- }
-};
diff --git a/tools/release-posts/lib/edit-post.ts b/tools/release-posts/lib/edit-post.ts
deleted file mode 100644
index b1b647b9a4c..00000000000
--- a/tools/release-posts/lib/edit-post.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-
-export type EditPostVariables = {
- hooks?: string;
- database?: string;
- templates?: string;
- contributors?: string;
-};
-
-export const editPostHTML = ( postContent: string, postVariables: EditPostVariables ) => {
- return postContent.replaceAll( /<!-- release:([a-z]+) -->.*?<!-- \/release:\1 -->/gm, ( match, key: string ) => {
- return `<!-- release:${ key } -->${ postVariables[ key as keyof EditPostVariables ] || '' }<!-- /release:${ key } -->`;
- } );
-};
diff --git a/tools/release-posts/lib/github-api.ts b/tools/release-posts/lib/github-api.ts
index 1e7de8c1cf3..16d79058eb7 100644
--- a/tools/release-posts/lib/github-api.ts
+++ b/tools/release-posts/lib/github-api.ts
@@ -34,8 +34,15 @@ export const getContributorData = async (
baseRef: string,
headRef: string
) => {
- const isValidAuthor = ( commit: { author?: { login?: string | null; } | null; } ) => {
- return !! commit.author && !! commit.author.login && ! commit.author.login.includes( 'bot' ) && 'invalid-email-address' !== commit.author.login;
+ const isValidAuthor = ( commit: {
+ author?: { login?: string | null } | null;
+ } ) => {
+ return (
+ !! commit.author &&
+ !! commit.author.login &&
+ ! commit.author.login.includes( 'bot' ) &&
+ 'invalid-email-address' !== commit.author.login
+ );
};
const octokit = new Octokit( {
auth: getEnvVar( 'GITHUB_ACCESS_TOKEN', true ),
@@ -55,9 +62,7 @@ export const getContributorData = async (
// add page 1 commits
allAuthors.push(
- ...commits
- .filter( isValidAuthor )
- .map( ( commit ) => commit.author )
+ ...commits.filter( isValidAuthor ).map( ( commit ) => commit.author )
);
for ( let i = 2; i <= pages; i++ ) {
@@ -92,44 +97,3 @@ export const getContributorData = async (
headRef,
} as ContributorData;
};
-
-export const getMostRecentFinal = async () => {
- const octokit = new Octokit( {
- auth: getEnvVar( 'GITHUB_ACCESS_TOKEN', true ),
- } );
-
- const release = await octokit.repos.getLatestRelease( {
- owner: 'woocommerce',
- repo: 'woocommerce',
- } );
-
- return release.data;
-};
-
-export const getMostRecentBeta = async () => {
- const octokit = new Octokit( {
- auth: getEnvVar( 'GITHUB_ACCESS_TOKEN', true ),
- } );
-
- const { data: releases } = await octokit.repos.listReleases( {
- owner: 'woocommerce',
- repo: 'woocommerce',
- } );
-
- const betaReleases = releases.filter(
- ( release ) =>
- release?.name && release.name.toLowerCase().includes( 'beta' )
- );
-
- if ( betaReleases.length === 0 ) {
- throw new Error( 'No beta releases found' );
- }
-
- const latestBetaRelease = betaReleases.reduce( ( latest, current ) => {
- const latestDate = new Date( latest.created_at );
- const currentDate = new Date( current.created_at );
- return currentDate > latestDate ? current : latest;
- } );
-
- return latestBetaRelease;
-};
diff --git a/tools/release-posts/lib/oauth-helper.ts b/tools/release-posts/lib/oauth-helper.ts
deleted file mode 100644
index 88e0de8eaab..00000000000
--- a/tools/release-posts/lib/oauth-helper.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * External dependencies
- */
-import express from 'express';
-import fetch from 'node-fetch';
-import open from 'open';
-import FormData from 'form-data';
-
-/**
- * Internal dependencies
- */
-import { renderTemplate } from './render-template';
-
-const getCode = (
- clientId: string,
- clientSecret: string,
- siteId: string,
- redirectUri: string,
- scope: string
-) => {
- return new Promise( async ( resolve, reject ) => {
- open(
- `https://public-api.wordpress.com/oauth2/authorize?client_id=${ clientId }&client_secret=${ clientSecret }&redirect_uri=${ redirectUri }&scope=${ scope }&blog=${ siteId }&response_type=code`
- );
-
- const uri = new URL( redirectUri );
-
- const app = express();
- const server = await app.listen( uri.port );
- let responded = false;
-
- const handle = setTimeout( () => {
- if ( ! responded ) {
- reject(
- 'Could not perform oauth redirect, please check your env settings.'
- );
- }
- }, 30000 );
-
- app.get( uri.pathname, async ( req, res ) => {
- responded = true;
- resolve( req.query.code );
- const response = await renderTemplate( 'oauth.ejs', {} );
- res.end( response );
- clearTimeout( handle );
- server.close();
- } );
- } );
-};
-
-export const getWordpressComAuthToken = async (
- clientId: string,
- clientSecret: string,
- siteId: string,
- redirectUri: string,
- scope: string
-) => {
- try {
- const code = await getCode(
- clientId,
- clientSecret,
- siteId,
- redirectUri,
- scope
- );
- const data = new FormData();
-
- data.append( 'client_id', clientId );
- data.append( 'client_secret', clientSecret );
- data.append( 'code', code );
- data.append( 'grant_type', 'authorization_code' );
- data.append( 'redirect_uri', redirectUri );
-
- const res = await fetch(
- 'https://public-api.wordpress.com/oauth2/token',
- {
- method: 'POST',
- headers: {
- Authorization:
- 'Basic ' +
- Buffer.from( clientId + ':' + clientSecret ).toString(
- 'base64'
- ),
- },
- body: data,
- }
- );
-
- if ( res.status !== 200 ) {
- const text = await res.text();
- throw new Error( `Error getting auth token ${ text }` );
- }
-
- const { access_token } = await res.json();
- return access_token;
- } catch ( e ) {
- if ( e instanceof Error ) {
- throw new Error( e.message );
- }
- }
-};
diff --git a/tools/release-posts/lib/process-changes.ts b/tools/release-posts/lib/process-changes.ts
deleted file mode 100644
index ea98031fe5c..00000000000
--- a/tools/release-posts/lib/process-changes.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-type AnalyzerChangeset = {
- hooks: [ string[] ];
- schema: Record< string, string >;
- db: { functionVersion: string; functionName: string };
- templates: Record< string, string >;
-};
-
-export const processChanges = ( changes: AnalyzerChangeset ) => {
- const hooks = Object.entries( changes.hooks ).map( ( [ , val ] ) => {
- return {
- name: val[ 0 ][ 0 ],
- description: val[ 0 ][ 1 ][ 3 ],
- };
- } );
-
- const schema = Object.entries( changes.schema ).map( ( [ key, val ] ) => {
- return { className: key, codeRef: val };
- } );
-
- const db = changes.db;
-
- const templates = Object.keys( changes.templates );
-
- return { hooks, schema, db, templates };
-};
diff --git a/tools/release-posts/package.json b/tools/release-posts/package.json
index 08030f77111..0869438cfc7 100644
--- a/tools/release-posts/package.json
+++ b/tools/release-posts/package.json
@@ -1,11 +1,10 @@
{
"name": "release-posts",
"version": "0.0.1",
- "description": "Automate release post generation for WordPress plugins",
- "main": " ",
+ "description": "Utilities for WooCommerce release posts",
"scripts": {
"lint": "tsc --noEmit",
- "release-post": "node -r ts-node/register ./commands/release-post/index.ts"
+ "release-post": "node -r ts-node/register ./index.ts"
},
"author": "Automattic",
"license": "GPL-2.0-or-later",
@@ -15,10 +14,8 @@
"devDependencies": {
"@tsconfig/node16": "^1.0.4",
"@types/ejs": "^3.1.5",
- "@types/express": "^4.17.21",
"@types/lodash.shuffle": "^4.2.9",
"@types/node": "^24.1.0",
- "@types/node-fetch": "^2.6.9",
"@types/semver": "^7.5.6",
"typescript": "5.7.x"
},
@@ -26,16 +23,10 @@
"@commander-js/extra-typings": "^0.1.0",
"@octokit/rest": "^19.0.13",
"@woocommerce/monorepo-utils": "workspace:*",
- "code-analyzer": "workspace:*",
"commander": "9.4.0",
"dotenv": "^15.0.1",
"ejs": "^3.1.9",
- "enquirer": "^2.4.1",
- "express": "^4.18.2",
- "form-data": "^4.0.6",
"lodash.shuffle": "^4.2.0",
- "node-fetch": "^2.7.0",
- "open": "^8.4.2",
"semver": "^7.5.4",
"ts-node": "^10.9.2"
},
@@ -44,7 +35,7 @@
"lint": {
"command": "lint",
"changes": [
- "commands/**/*.ts",
+ "index.ts",
"lib/**/*.ts"
]
}
diff --git a/tools/release-posts/program.ts b/tools/release-posts/program.ts
deleted file mode 100644
index 8d685b3799a..00000000000
--- a/tools/release-posts/program.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * External dependencies
- */
-import { Command } from '@commander-js/extra-typings';
-
-export const program = new Command();
-
-program
- .name( 'post' )
- .description( 'CLI to automate generation of posts for beta and release.' )
- .version( '0.0.1' );
diff --git a/tools/release-posts/templates/beta-release.ejs b/tools/release-posts/templates/beta-release.ejs
deleted file mode 100644
index d9dcf8eb7d9..00000000000
--- a/tools/release-posts/templates/beta-release.ejs
+++ /dev/null
@@ -1,164 +0,0 @@
-<!-- wp:paragraph -->
-<p>
- Beta <%= betaNumber %> for the <%=
- finalReleaseDate.toLocaleDateString('en-US', {month: 'long', day:
- 'numeric'}) %> release of WooCommerce is now available for testing! You can
- either
- <a
- href="https://downloads.wordpress.org/plugin/woocommerce.<%= version.version %>.zip"
- target="_blank"
- rel="noreferrer noopener"
- >download it directly from WordPress.org</a
- >
- or install our
- <a
- rel="noreferrer noopener"
- href="https://woocommerce.wordpress.com/2018/07/30/woocommerce-beta-tester-2-0-0/"
- target="_blank"
- >WooCommerce Beta Tester Plugin</a
- >.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading -->
-<h2 class="wp-block-heading">Highlights</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>
- Since the release of
- <a href="<%= lastReleasePostUrl %>"><%= prettyPreviousVersion %></a>, the
- following changes have been made:
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:list -->
-<ul>
- <!-- wp:list-item -->
- <li>List your changes here.</li>
- <!-- /wp:list-item -->
-</ul>
-<!-- /wp:list -->
-
-<!-- wp:paragraph -->
-<p>
- For the complete list, view the <a
- href="https://github.com/woocommerce/woocommerce/blob/release/<%= version.major %>.<%= version.minor %>/plugins/woocommerce/readme.txt"
- >changelog</a
- > in the readme for this release.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading {"anchor":"actions-and-filters"} -->
-<h2 class="wp-block-heading" id="actions-and-filters">Actions and Filters</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>Insert action and filter changes here.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading {"anchor":"database-changes"} -->
-<h2 class="wp-block-heading" id="database-changes">Database Changes</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>Insert db changes here.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading {"anchor":"template-changes"} -->
-<h2 class="wp-block-heading" id="template-changes">Template Changes</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>Insert template changes here.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading {"anchor":"release-schedule"} -->
-<h2 class="wp-block-heading" id="release-schedule">Release Schedule</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>
- We're still on track for our planned <%=
- finalReleaseDate.toLocaleDateString('en-US', {month: 'long', day:
- 'numeric'}) %> release.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:table -->
-<figure class="wp-block-table">
- <table>
- <tbody>
- <tr>
- <td><strong>Version</strong></td>
- <td><strong>Release</strong></td>
- </tr>
- <tr>
- <td>Release Candidate</td>
- <td>
- <%= rcReleaseDate.toLocaleDateString('en-US', { month:
- 'long', day: 'numeric', year: 'numeric' }) %>
- </td>
- </tr>
- <tr>
- <td>Final Release</td>
- <td>
- <%= finalReleaseDate.toLocaleDateString('en-US', { month:
- 'long', day: 'numeric', year: 'numeric' }) %>
- </td>
- </tr>
- </tbody>
- </table>
-</figure>
-<!-- /wp:table -->
-
-<!-- wp:heading {"anchor":"testing"} -->
-<h2 class="wp-block-heading" id="testing">Testing</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>
- If you'd like to dive in and help test this new release, our handy <a
- href="https://woocommerce.com/products/woocommerce-beta-tester/"
- target="_blank"
- >WooCommerce Beta Tester plugin</a
- > allows you to switch between beta versions and release candidates.
- You can also <a
- href="https://downloads.wordpress.org/plugin/woocommerce.<%= version.version %>.zip"
- target="_blank"
- rel="noreferrer noopener"
- >download the release from WordPress.org</a
- >.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p>
- A set of testing instructions has been published on our <a
- href="https://github.com/woocommerce/woocommerce/wiki/Release-Testing-Instructions-WooCommerce-<%= version.major %>.<%= version.minor %>"
- target="_blank"
- rel="noreferrer noopener"
- >Wiki page in GitHub</a
- >. We've also posted <a
- href="https://woocommerce.wordpress.com/2015/07/25/how-to-beta-test-woocommerce/"
- target="_blank"
- >a helpful writeup on beta testing</a
- > to help get you started.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p>
- If you discover any bugs during the testing process, please let us know
- by <a
- href="https://github.com/woocommerce/woocommerce/issues/new?assignees=&labels=&template=1-bug-report.yml&title=[<%= version.major %>.<%= version.minor %> beta]: Title of the issue"
- target="_blank"
- rel="noreferrer noopener"
- >logging a report in GitHub</a
- >.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p></p>
-<!-- /wp:paragraph -->
diff --git a/tools/release-posts/templates/database.ejs b/tools/release-posts/templates/database.ejs
deleted file mode 100644
index de0523954fe..00000000000
--- a/tools/release-posts/templates/database.ejs
+++ /dev/null
@@ -1,30 +0,0 @@
-<!-- wp:heading -->
-<h2 id="database-changes">Database Changes</h2>
-<!-- /wp:heading -->
-
-<% if (changes.db) { %>
- <!-- wp:heading -->
- <h3 id="db-updates">DB Updates</h3>
- <!-- /wp:heading -->
-
- <!-- wp:table -->
- <figure class="wp-block-table">
- <table>
- <tbody>
- <tr>
- <th>
- <strong>Function Name</strong>
- </th>
- </tr>
- <tr>
- <td><code><%= changes.db.functionName %></code></td>
- </tr>
- </tbody>
- </table>
- </figure>
- <!-- /wp:table -->
-<% } else { %>
- <!-- wp:paragraph -->
- <p>There are no database changes in this release.</p>
- <!-- /wp:paragraph -->
-<% } %>
diff --git a/tools/release-posts/templates/hooks.ejs b/tools/release-posts/templates/hooks.ejs
deleted file mode 100644
index 6133b5cae76..00000000000
--- a/tools/release-posts/templates/hooks.ejs
+++ /dev/null
@@ -1,31 +0,0 @@
-<!-- wp:heading -->
-<h2 id="actions-and-filters">Actions and Filters</h2>
-<!-- /wp:heading -->
-
-<% if (changes.hooks.size) { %>
- <!-- wp:table -->
- <figure class="wp-block-table">
- <table>
- <tbody>
- <tr>
- <th><strong>Filter</strong></th>
- <th><strong>Description</strong></th>
- <th><strong>GitHub Link</strong></th>
- </tr>
- <% changes.hooks.forEach(({ name, description, ghLink }) => { %>
- <tr>
- <td><%= name %></td>
- <td><%= description %></td>
- <td><a target="_blank" href="<%= ghLink %>">Link</a></td>
- </tr>
- <% }) %>
- <!-- end each hook change-->
- </tbody>
- </table>
- </figure>
- <!-- /wp:table -->
-<% } else { %>
- <!-- wp:paragraph -->
- <p>This release doesn\'t add any actions or filters.</p>
- <!-- /wp:paragraph -->
-<% } %>
diff --git a/tools/release-posts/templates/oauth.ejs b/tools/release-posts/templates/oauth.ejs
deleted file mode 100644
index 248ea63d171..00000000000
--- a/tools/release-posts/templates/oauth.ejs
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
- <head>
- <title>Authentication Success</title>
- </head>
-
- <body>Authentication successful, please return to the console to complete the process.</body>
-</html>
diff --git a/tools/release-posts/templates/rc-release.ejs b/tools/release-posts/templates/rc-release.ejs
deleted file mode 100644
index a473a524d8f..00000000000
--- a/tools/release-posts/templates/rc-release.ejs
+++ /dev/null
@@ -1,115 +0,0 @@
-<!-- wp:paragraph -->
-<p>Release Candidate <%= rcNumber %> for the <%=
- finalReleaseDate.toLocaleDateString('en-US', {month: 'long', day:
- 'numeric'}) %> release of WooCommerce is now available for testing! You can
- either
- <a
- href="https://downloads.wordpress.org/plugin/woocommerce.<%= version.version %>.zip"
- target="_blank"
- rel="noreferrer noopener"
- >download it directly from WordPress.org</a
- >
- or install our
- <a
- rel="noreferrer noopener"
- href="https://woocommerce.wordpress.com/2018/07/30/woocommerce-beta-tester-2-0-0/"
- target="_blank"
- >WooCommerce Beta Tester Plugin</a
- >.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading -->
-<h2 class="wp-block-heading">What's New?</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>Since the release of
- <a href="<%= lastReleasePostUrl %>"><%= prettyPreviousVersion %></a>, the
- following changes have been made:
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:list -->
-<ul>
- <!-- wp:list-item -->
- <li>List the changes to the release here.</li>
- <!-- /wp:list-item -->
-</ul>
-<!-- /wp:list -->
-
-<!-- wp:heading -->
-<h2 class="wp-block-heading">Actions and Filters</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>Insert action and filter changes here.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading -->
-<h2 class="wp-block-heading">Template Changes</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>Insert template changes here.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading {"anchor":"release-schedule"} -->
-<h2 class="wp-block-heading" id="release-schedule">Release Schedule</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>We're still on track for our planned <%=
- finalReleaseDate.toLocaleDateString('en-US', {month: 'long', day:
- 'numeric'}) %> release of WooCommerce <%= version.major %>.<%= version.minor
- %>.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading {"anchor":"testing"} -->
-<h2 class="wp-block-heading" id="testing">Testing</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>If you'd like to dive in and help test this new release, our handy <a
- href="https://woocommerce.com/products/woocommerce-beta-tester/"
- target="_blank"
- >WooCommerce Beta Tester plugin</a
- > allows you to switch between beta versions and release candidates.
- You can also <a
- href="https://downloads.wordpress.org/plugin/woocommerce.<%= version.version %>.zip"
- target="_blank"
- rel="noreferrer noopener"
- >download the release from WordPress.org</a
- >.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p>A set of testing instructions has been published on our <a
- href="https://github.com/woocommerce/woocommerce/wiki/Release-Testing-Instructions-WooCommerce-<%= version.major %>.<%= version.minor %>"
- target="_blank"
- rel="noreferrer noopener"
- >Wiki page in GitHub</a
- >. We've also posted <a
- href="https://woocommerce.wordpress.com/2015/07/25/how-to-beta-test-woocommerce/"
- target="_blank"
- >a helpful writeup on beta testing</a
- > to help get you started.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p>If you discover any bugs during the testing process, please let us know
- by <a
- href="https://github.com/woocommerce/woocommerce/issues/new?assignees=&labels=&template=1-bug-report.yml&title=[<%= version.major %>.<%= version.minor %> RC]: Title of the issue"
- target="_blank"
- rel="noreferrer noopener"
- >logging a report in GitHub</a
- >.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p></p>
-<!-- /wp:paragraph -->
diff --git a/tools/release-posts/templates/release.ejs b/tools/release-posts/templates/release.ejs
deleted file mode 100644
index 615b7ae4ddd..00000000000
--- a/tools/release-posts/templates/release.ejs
+++ /dev/null
@@ -1,64 +0,0 @@
-<!-- wp:heading -->
-<h1><%= title %></h1>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>We are pleased to announce the release of WooCommerce <%= displayVersion %>. This release should be backwards compatible with the previous version.</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p>This release contains:</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:list -->
-<ul>
- <% for ( const packageName in contributors ) { %>
- <% const {org, repo, contributors: packageContributors, totalCommits, baseRef, headRef} = contributors[packageName] %>
- <% if ( packageContributors ) { %>
- <li>
- <a target="_blank" href="https://github.com/<%= org %>/<%= repo %>/compare/<%= baseRef %>...<%= headRef %>">
- <%= totalCommits %> commits from <%= packageContributors.length %> contributors
- </a>
- in <%= packageName %>.
- </li>
- <% } %>
- <% } %>
-</ul>
-<!-- /wp:list -->
-
-<!-- wp:paragraph -->
-<p>
- As always, we recommend creating a backup of your site and making sure that your theme and any other plugins are compatible before updating.
- You can check out <a href="https://woocommerce.com/document/how-to-update-woocommerce/" target="_blank">this update guide</a> for more information.
-</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:heading -->
-<h2 id="what-s-new-in-<%= displayVersion %>">What's new in <%= displayVersion %>?</h2>
-<!-- /wp:heading -->
-
-<!-- wp:paragraph -->
-<p>WHAT'S NEW ITEMS</p>
-<!-- /wp:paragraph -->
-
-<!-- wp:paragraph -->
-<p>
- These are just some of the changes that are included in WooCommerce <%= displayVersion %>.
- You can find the complete changelog for this release in the <a href="https://github.com/woocommerce/woocommerce/blob/release/<%= displayVersion %>/changelog.txt" target="_blank">changelog.txt file</a>.
-</p>
-<!-- /wp:paragraph -->
-
-
-<!-- release:hooks --><%- include( 'hooks' ) %><!-- /release:hooks -->
-<!-- release:database --><%- include( 'database' ) %><!-- /release:database -->
-<!-- release:templates --><%- include( 'templates' ) %><!-- /release:templates -->
-
-<!-- wp:heading -->
-<h2 id="deprecations">Deprecations</h2>
-<!-- /wp:heading -->
-<!-- wp:paragraph -->
-<p>There are no deprecations in this release.</p>
-<!-- /wp:paragraph -->
-
-<!-- release:contributors--><%- include('contributors') %><!-- /release:contributors -->
-
diff --git a/tools/release-posts/templates/templates.ejs b/tools/release-posts/templates/templates.ejs
deleted file mode 100644
index b03b96ed8b7..00000000000
--- a/tools/release-posts/templates/templates.ejs
+++ /dev/null
@@ -1,38 +0,0 @@
-<!-- wp:heading -->
-<h2 id="template-changes">Template Changes</h2>
-<!-- /wp:heading -->
-
-<% if (changes.templates.size) { %>
- <!-- wp:table -->
- <figure class="wp-block-table">
- <table>
- <thead>
- <th>
- <strong>Template</strong>
- </th>
- <th>
- <strong>GitHub Link</strong>
- </th>
- </thead>
- <tbody>
-
- <!-- for each template change (template / description) -->
- <% changes.templates.forEach((change) => { %>
- <tr>
- <td><%= change.filePath %></td>
- <td>
- <% change.pullRequests.forEach( ( pullRequest ) => { %>
- <a href="https://github.com/woocommerce/woocommerce/pull/<%= pullRequest %>">#<%= pullRequest %></a>
- <% }) %>
- </td>
- </tr>
- <% }) %>
- </tbody>
- </table>
- </figure>
- <!-- /wp:table -->
-<% } else { %>
- <!-- wp:paragraph -->
- <p>There are no template changes in this release.</p>
- <!-- /wp:paragraph -->
-<% } %>
diff --git a/tools/release-posts/tsconfig.json b/tools/release-posts/tsconfig.json
index beac0b7c4d3..d10ad85eeb5 100644
--- a/tools/release-posts/tsconfig.json
+++ b/tools/release-posts/tsconfig.json
@@ -3,10 +3,7 @@
"compilerOptions": {
"module": "Node16",
"moduleResolution": "Node16",
- "typeRoots": [
- "./typings",
- "./node_modules/@types"
- ]
+ "typeRoots": [ "./typings", "./node_modules/@types" ]
},
"ts-node": {
"transpileOnly": true,