Skip to content

WDSBT-241 - Add cards pattern category and fixes to the version updat… #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v22.16.0
v22.17.1
7 changes: 7 additions & 0 deletions inc/hooks/register-block-pattern-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ function register_custom_block_pattern_categories() {
'description' => __( 'A collection of template patterns designed for WDS BT.', 'wdsbt' ),
)
);
register_block_pattern_category(
'cards',
array(
'label' => __( 'Cards', 'wdsbt' ),
'description' => __( 'A collection of card patterns designed for WDS BT.', 'wdsbt' ),
)
);

// Remove default patterns.
remove_theme_support( 'core-block-patterns' );
Expand Down
1 change: 0 additions & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pre-commit:
echo "$CONFLICT_FILES"
exit 1
fi
stage: false

exit-status:
run: echo "✅ All pre-commit checks passed!"
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"url": "https://github.com/WebDevStudios/wds-bt/issues"
},
"engines": {
"node": ">=20.0.0",
"node": ">=22.0.0",
"npm": ">=10"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: webdevstudios, khleomix, bgardner
Requires at least: 6.4
Tested up to: 6.4
Requires PHP: 8.2
Stable tag: 0.1.0
Stable tag: 1.1.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down
54 changes: 36 additions & 18 deletions updateVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (!version) {
process.exit(1);
}

const updateJsonFile = (filePath) => {
const updateJsonFile = (filePath, label = filePath) => {
if (!fs.existsSync(filePath)) {
return;
}
Expand All @@ -17,7 +17,7 @@ const updateJsonFile = (filePath) => {

if (jsonData.version === version) {
console.log(
`No update needed for ${filePath} (already version ${version}).`
`No update needed for ${label} (already version ${version}).`
);
return;
}
Expand All @@ -28,36 +28,54 @@ const updateJsonFile = (filePath) => {
JSON.stringify(jsonData, null, 2) + '\n',
'utf8'
);
console.log(`Updated version in ${filePath} to ${version}`);
console.log(`Updated version in ${label} to ${version}`);
};

const updateTextFile = (filePath, regex, replacement) => {
const updateTextFile = (filePath, regex, replacement, label = filePath) => {
if (!fs.existsSync(filePath)) {
return;
}

let fileContent = fs.readFileSync(filePath, 'utf8');
const match = fileContent.match(regex);

if (match) {
const currentVersion = match[2];
if (currentVersion === version) {
console.log(
`No update needed for ${label} (already version ${version}).`
);
return;
}

if (regex.test(fileContent)) {
fileContent = fileContent.replace(regex, replacement);
fs.writeFileSync(filePath, fileContent, 'utf8');
console.log(`Updated version in ${filePath} to ${version}`);
console.log(`Updated version in ${label} to ${version}`);
} else {
console.warn(
`Version pattern not found in ${filePath}, skipping update.`
);
console.warn(`Version pattern not found in ${label}, skipping update.`);
}
};

// Update version in style.css
updateTextFile('./style.css', /(Version:\s*)([^\n]+)/, `$1${version}`);

// Update version in README.md
updateTextFile('./README.md', /(## Version:\s*)([^\n]+)/, `$1${version}`);

// Update JSON-based files
updateJsonFile('./package.json');
updateJsonFile('./composer.json');
// Update all relevant files
updateTextFile(
'./style.css',
/(Version:\s*)([^\n]+)/,
`$1${version}`,
'style.css'
);
updateTextFile(
'./README.md',
/(## Version:\s*)([^\n]+)/,
`$1${version}`,
'README.md'
);
updateTextFile(
'./readme.txt',
/(Stable tag:\s*)([^\n]+)/,
`$1${version}`,
'readme.txt'
);
updateJsonFile('./package.json', 'package.json');

console.log('Version update process completed.');
/* eslint-enable no-console */