Skip to content

Commit

Permalink
CHANGELOG and built release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Jan 9, 2024
1 parent 06d3d75 commit a2aae7a
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 64 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/built-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Built Release

on:
push:
branches:
- develop
- main
- production

jobs:
built-release:
uses: alleyinteractive/.github/.github/workflows/built-release.yml@main
with:
node: 16
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## 1.4.0

* Migrates code into the `Alley\WP\Asset_Manager` namespace. Legacy classes such
as `Asset_Manager_Scripts` and `Asset_Manager_Styles` are aliased to their new
namespace for backward compatibility. Helper functions are left un-namespaced.
* Adds a dependency on Composer autoloader. For submodules, you can track the
`production-built` branch of the plugin or any tagged release (which will be
built) to include the dependencies.

## 1.3.6

* Adds support for running the plugin on a Windows hosting environment (#57)
Expand Down
18 changes: 4 additions & 14 deletions asset-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
* @package AssetManager
*/

/*
Plugin Name: Asset Manager
Plugin URI: https://github.com/alleyinteractive/wp-asset-manager
Description: Add more robust functionality to enqueuing static assets
Author: Alley Interactive
Version: 1.4.0
License: GPLv2 or later
Author URI: https://www.alleyinteractive.com/
*/

/**
* Filesystem path to AssetManager.
*/
Expand All @@ -28,14 +18,14 @@
} else {
add_action(
'admin_notices',
function() {
function () {
?>
<div class="notice notice-error">
<p>
<?php
esc_html_e(
'Asset Manager is not installed. Please run `composer install` from the plugin directory.',
'asset-manager'
'Asset Manager is not installed. Please switch to a tagged release or track the `production-built` branch.',
'am'
);
?>
</p>
Expand All @@ -54,7 +44,7 @@ class_alias( \Alley\WP\Asset_Manager\Preload::class, 'Asset_Manager_Preload' );
class_alias( \Alley\WP\Asset_Manager\SVG_Sprite::class, 'Asset_Manager_SVG_Sprite' );

// Require the helpers that are used to interact with the plugin.
require_once __DIR__ . '/inc/helpers.php';
require_once __DIR__ . '/src/helpers.php';

/**
* Map plugin meta capabilities.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"extra": {
"wordpress-autoloader": {
"autoload": {
"Alley\\WP\\Asset_Manager\\": "inc/"
"Alley\\WP\\Asset_Manager\\": "src/"
},
"autoload-dev": {
"Alley\\WP\\Asset_Manager\\Tests\\": "tests/"
Expand Down
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@alleyinteractive/wp-asset-manager",
"version": "1.4.0",
"description": "Asset Manager is a toolkit for managing front-end assets and more tightly controlling where, when, and how they're loaded.",
"scripts": {
"build": "echo 'No build step defined'",
"release": "npx @alleyinteractive/create-release@latest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/alleyinteractive/wp-asset-manager.git"
},
"author": "",
"license": "GPL-2.0+",
"bugs": {
"url": "https://github.com/alleyinteractive/wp-asset-manager/issues"
},
"homepage": "https://github.com/alleyinteractive/wp-asset-manager#readme"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 12 additions & 13 deletions inc/class-svg-sprite.php → src/class-svg-sprite.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
namespace Alley\WP\Asset_Manager;

use DOMDocument;

use DOMElement;
use DOMText;

/**
* Asset_Manager_SVG_Sprite class.
Expand All @@ -22,21 +23,21 @@ class SVG_Sprite {
*
* @var string
*/
public static $_svg_directory; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
public static ?string $_svg_directory; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore

/**
* Array for attributes to add to each symbol.
*
* @var array
*/
public static $_global_attributes; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
public static ?array $_global_attributes; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore

/**
* The sprite document.
*
* @var DOMDocument
*/
public $sprite_document;
public DOMDocument $sprite_document;

/**
* The sprite document.
Expand All @@ -57,14 +58,14 @@ class SVG_Sprite {
*
* @var array
*/
public $sprite_map = [];
public array $sprite_map = [];

/**
* Allowed tags and attributes for echoing <svg> and <use> elements.
*
* @var array
*/
public $kses_svg_allowed_tags = [
public array $kses_svg_allowed_tags = [
'svg' => [],
'use' => [
'href' => true,
Expand All @@ -83,12 +84,10 @@ protected function __construct() {
*/
add_filter(
'safe_style_css',
function ( $styles ) {
$styles[] = 'left';
$styles[] = 'overflow';
$styles[] = 'position';
return $styles;
}
fn ( $styles ) => [
...array_values( $styles ),
[ 'left', 'overflow', 'position' ],
],
);

add_filter( 'wp_kses_allowed_html', [ $this, 'extend_kses_post_with_use_svg' ] );
Expand Down Expand Up @@ -395,7 +394,7 @@ public function add_asset( $asset ): void {
return;
}

list( $asset, $symbol ) = $this->create_symbol( $asset );
[ $asset, $symbol ] = $this->create_symbol( $asset );

if ( ! ( $symbol instanceof DOMElement ) ) {
return;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion inc/helpers.php → src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* @return bool True if the path is valid, false otherwise.
*/
function am_validate_path( string $path ) : bool {
function am_validate_path( string $path ): bool {
return in_array( validate_file( $path ), [ 0, 2 ], true ) && file_exists( $path );
}
}
Expand Down
File renamed without changes.
4 changes: 1 addition & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
* @package WP_Irving
*/

use function Mantle\Testing\tests_add_filter;

require_once __DIR__ . '/../vendor/autoload.php';

\Mantle\Testing\manager()
->loaded( fn () => require dirname( __DIR__ ) . '/asset-manager.php' )
->loaded( fn () => require dirname( __DIR__ ) . '/wp-asset-manager.php' )
->install();

if ( ! function_exists( 'get_echo' ) ) :
Expand Down
49 changes: 17 additions & 32 deletions tests/class-test-case.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ abstract class Test_Case extends \Mantle\Testkit\Test_Case {
'src' => 'http://www.example.org/wp-content/themes/example/static/css/test-two.css',
];

public $global_attributes;
public $svg_directory;
public array $global_attributes = [ 'focusable' => 'false', 'aria-hidden' => 'true' ];

public string $svg_directory;

protected function setUp(): void {
parent::setUp();
Expand All @@ -41,39 +42,23 @@ protected function setUp(): void {
remove_all_filters( 'am_asset_conditions', 10 );
add_filter(
'am_asset_conditions',
function() {
return [
'global' => true,
'article_post_type' => true,
'single' => true,
'archive' => false,
'has_slideshow' => false,
'has_video' => false,
];
}
);
add_filter(
'am_inline_script_context',
function() {
return 'assetContext';
}
fn () => [
'global' => true,
'article_post_type' => true,
'single' => true,
'archive' => false,
'has_slideshow' => false,
'has_video' => false,
]
);

$this->svg_directory = dirname( __FILE__ ) . '/mocks/';
add_filter(
'am_modify_svg_directory',
function() {
return $this->svg_directory;
}
);
add_filter( 'am_inline_script_context', fn () => 'assetContext' );

$this->svg_directory = __DIR__ . '/mocks/';

add_filter( 'am_modify_svg_directory', fn () => $this->svg_directory );
$this->global_attributes = [ 'focusable' => 'false', 'aria-hidden' => 'true' ];
add_filter(
'am_global_svg_attributes',
function( $attrs ) {
return array_merge( $attrs, $this->global_attributes );
}
);
add_filter( 'am_global_svg_attributes', fn ( $attrs ) => array_merge( $attrs, $this->global_attributes ) );

$this->reset_assets();
$this->acting_as( 'administrator' );
Expand All @@ -99,7 +84,7 @@ public function reset_assets() {
'href' => true,
],
];
SVG_Sprite::$_global_attributes = null;
SVG_Sprite::$_global_attributes = [];
SVG_Sprite::$_svg_directory = null;
SVG_Sprite::instance()->create_sprite_sheet();

Expand Down
19 changes: 19 additions & 0 deletions wp-asset-manager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Asset Manager plugin file
*
* @package AssetManager
*/

/*
Plugin Name: Asset Manager
Plugin URI: https://github.com/alleyinteractive/wp-asset-manager
Description: Add more robust functionality to enqueuing static assets
Author: Alley Interactive
Version: 1.4.0
License: GPLv2 or later
Author URI: https://alley.com
*/

// Require the main plugin file left as the original name for backwards compatibility.
require_once __DIR__ . '/asset-manager.php';

0 comments on commit a2aae7a

Please sign in to comment.