mirror of
https://github.com/woocommerce/woocommerce.git
synced 2025-08-18 18:41:51 +08:00
* Add the mirror PHP package workflow and cleanup script WOOPLUG-3249 * Rename JS config package for email editor PHP package This is to align with the naming in the JS package. WOOPLUG-3249 * Add changelog WOOPLUG-3249 * Update readme.md in the editor PHP package WOOPLUG-3249 * Update email editor package and tooling to support packages-prepare workflow WOOPLUG-3249 * Add build:composer-package script WOOPLUG-3249 * Update the PHP package mirror workflow to use prepared commands WOOPLUG-3249 * Add an extra readme.md for the mirrored repository WOOPLUG-3249 * Remove the unused mirror cleanup script WOOPLUG-3249 * Add tyhehints to Formatter::getReleaseLink WOOPLUG-3249 * Use the package name from composer.json for creating the release link WOOPLUG-3249 * Merge the build path export to the build package step of the PHP package mirror workflow WOOPLUG-3249 * Review: fix package prepare for initial release. * Review: package build tweaks. * Review: workflow tweaks. * Review: cleanup. --------- Co-authored-by: Vladimir Reznichenko <kalessil@gmail.com>
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Package_Formatter class
|
|
*
|
|
* @package WooCommerce
|
|
*/
|
|
|
|
namespace Automattic\WooCommerce\MonorepoTools\Changelogger;
|
|
|
|
use Automattic\Jetpack\Changelogger\FormatterPlugin;
|
|
|
|
/**
|
|
* Jetpack Changelogger Formatter for WooCommerce packages
|
|
*/
|
|
|
|
require_once 'class-formatter.php';
|
|
|
|
/**
|
|
* Jetpack Changelogger Formatter for WooCommerce Packages
|
|
*
|
|
* Class Formatter
|
|
*/
|
|
class Package_Formatter extends Formatter implements FormatterPlugin {
|
|
/**
|
|
* Prologue text.
|
|
*
|
|
* @var string
|
|
*/
|
|
public $prologue = "# Changelog \n\nThis project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).";
|
|
|
|
/**
|
|
* Return the epilogue string based on the package being released.
|
|
*/
|
|
public function getEpilogue() {
|
|
$cwd = getcwd();
|
|
$pos = stripos( $cwd, 'packages/js/' );
|
|
$package = substr( $cwd, $pos + 12 );
|
|
|
|
return '[See legacy changelogs for previous versions](https://github.com/woocommerce/woocommerce/blob/68581955106947918d2b17607a01bdfdf22288a9/packages/js/' . $package . '/CHANGELOG.md).';
|
|
}
|
|
|
|
/**
|
|
* Get Release link given a version number.
|
|
*
|
|
* @throws \InvalidArgumentException When directory parsing fails.
|
|
* @param string $version Release version.
|
|
*
|
|
* @return string Link to the version's release.
|
|
*/
|
|
public function getReleaseLink( string $version ): string {
|
|
// Capture anything past /woocommerce in the current working directory.
|
|
preg_match( '/\/packages\/js\/(.+)/', getcwd(), $path );
|
|
|
|
if ( ! count( $path ) ) {
|
|
throw new \InvalidArgumentException( 'Invalid directory.' );
|
|
}
|
|
|
|
return 'https://www.npmjs.com/package/@woocommerce/' . $path[1] . '/v/' . $version;
|
|
}
|
|
}
|