Skip to content

Commit

Permalink
Add Husky, lint-staged to package.json. Fixes #23
Browse files Browse the repository at this point in the history
- Add `husky` and configuration
- Add `lint-staged` and configuration
- Adjust `package.json` scripts
- Alphabetize scripts in `package.json` for easy readability
- Update URL in `"homepage"` object
- Remove `npx` prefix from scripts
- Update `"bugs"` object in `package.json`
  • Loading branch information
Herm71 authored Sep 29, 2022
1 parent 4a67732 commit d59e7ef
Show file tree
Hide file tree
Showing 12 changed files with 1,148 additions and 295 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
name: Build and release

on:
push:
tags:
- "v*.*.*"
- "v*.*.*-rc.*"
push:
tags:
- 'v*.*.*'
- 'v*.*.*-rc.*'

permissions:
contents: write
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
node-version: 14
cache: "npm"
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
node-version: 14
cache: 'npm'

- name: Install Node dependencies
run: npm install
- name: Install Node dependencies
run: npm install

- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Install PHP dependencies
run: composer install --no-progress
- name: Install PHP dependencies
run: composer install --no-progress

- name: Build theme
run: npm run build
- name: Build theme
run: npm run build

- name: Package theme
run: ./node_modules/.bin/wp-scripts plugin-zip
- name: Package theme
run: ./node_modules/.bin/wp-scripts plugin-zip

- name: Release
uses: softprops/action-gh-release@v1
with:
files: ucsc-2022.zip
generate_release_notes: true
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ucsc-2022.zip
generate_release_notes: true
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
20 changes: 10 additions & 10 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ucsc_setup() {
/*
* Load additional block styles.
*/
$styled_blocks = array( 'button', 'post-template', 'post-author', 'site-title', 'query-pagination', 'post-content', 'rss', 'post-title', 'post-comments', 'navigation', 'list', 'separator', 'latest-posts', 'quote', 'image', 'search');
$styled_blocks = array( 'button', 'post-template', 'post-author', 'site-title', 'query-pagination', 'post-content', 'rss', 'post-title', 'post-comments', 'navigation', 'list', 'separator', 'latest-posts', 'quote', 'image', 'search' );
foreach ( $styled_blocks as $block_name ) {
$args = array(
'handle' => "ucsc-$block_name",
Expand Down Expand Up @@ -274,7 +274,7 @@ function ucsc_add_breadcrumbs( $block_content = '', $block = array() ) {
if ( ucsc_breadcrumbs_constructor() ) {
$breadcrumbs = ucsc_breadcrumbs_constructor();
}
if ( is_singular() && isset($breadcrumbs) ) {
if ( is_singular() && isset( $breadcrumbs ) ) {
if ( isset( $block['blockName'] ) && 'core/post-title' === $block['blockName'] ) {
if ( isset( $block['attrs']['level'] ) && isset( $block['attrs']['className'] ) && $block['attrs']['className'] === 'primary-post-title' ) {
$html = str_replace( $block_content, $breadcrumbs . $block_content, $block_content );
Expand All @@ -291,16 +291,16 @@ function ucsc_add_breadcrumbs( $block_content = '', $block = array() ) {
* Note: this does not prevent editing of blocks. Only moving/removing
*/
add_filter(
'block_editor_settings_all',
function( $settings, $context ) {
// Allow for the Administrator role and above
'block_editor_settings_all',
function( $settings, $context ) {
// Allow for the Administrator role and above
// https://wordpress.org/support/article/roles-and-capabilities/.
$settings['canLockBlocks'] = current_user_can( 'switch_themes' );
$settings['canLockBlocks'] = current_user_can( 'switch_themes' );

return $settings;
},
10,
2
return $settings;
},
10,
2
);

/**
Expand Down
4 changes: 2 additions & 2 deletions header-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/

/** See: https://github.com/WordPress/gutenberg/issues/39207#issuecomment-1087347901 */
$ucsc_header = do_blocks( '<!-- wp:template-part {"slug":"ucsc-header","theme":"ucsc-2022","className":"ucsc-header"} /-->' . '<!-- wp:template-part {"slug":"site-header","theme":"ucsc-2022","className":"site-header"} /-->' );
$ucsc_header = do_blocks( '<!-- wp:template-part {"slug":"ucsc-header","theme":"ucsc-2022","className":"ucsc-header"} /-->' . '<!-- wp:template-part {"slug":"site-header","theme":"ucsc-2022","className":"site-header"} /-->' );
$GLOBALS['ucsc_plugin_content'] = do_blocks( '<!-- wp:template-part {"className":"plugin-content","slug":"content-plugin","theme":"ucsc-2022"} /-->' );
$GLOBALS['ucsc_footer'] = do_blocks( '<!-- wp:template-part {"slug":"site-footer","theme":"ucsc-2022","className":"site-footer"} /-->' . '<!-- wp:template-part {"slug":"ucsc-footer","theme":"ucsc-2022","className":"ucsc-footer"} /-->' );
$GLOBALS['ucsc_footer'] = do_blocks( '<!-- wp:template-part {"slug":"site-footer","theme":"ucsc-2022","className":"site-footer"} /-->' . '<!-- wp:template-part {"slug":"ucsc-footer","theme":"ucsc-2022","className":"ucsc-footer"} /-->' );
?>
<!DOCTYPE html>
<html lang="en-US">
Expand Down
4 changes: 4 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'*.{css,scss}': 'npm run lint:style',
'*.js': 'npm run format',
};
Loading

0 comments on commit d59e7ef

Please sign in to comment.