Skip to content

Commit 9733a3b

Browse files
committed
WDSBT-241 - Add cards pattern category and fixes to the version update script
1 parent 9f8273a commit 9733a3b

File tree

8 files changed

+1073
-794
lines changed

8 files changed

+1073
-794
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "webdevstudios/wds-bt",
3-
"version": "1.1.0",
43
"description": "A FSE/Gutenberg block starter theme from WebDevStudios.",
54
"type": "wordpress-theme",
65
"license": "GPL-2.0-or-later",

composer.lock

Lines changed: 139 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/hooks/register-block-pattern-categories.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ function register_custom_block_pattern_categories() {
4040
'description' => __( 'A collection of template patterns designed for WDS BT.', 'wdsbt' ),
4141
)
4242
);
43+
register_block_pattern_category(
44+
'cards',
45+
array(
46+
'label' => __( 'Cards', 'wdsbt' ),
47+
'description' => __( 'A collection of card patterns designed for WDS BT.', 'wdsbt' ),
48+
)
49+
);
4350

4451
// Remove default patterns.
4552
remove_theme_support( 'core-block-patterns' );

lefthook.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pre-commit:
4848
echo "$CONFLICT_FILES"
4949
exit 1
5050
fi
51-
stage: false
5251
5352
exit-status:
5453
run: echo "✅ All pre-commit checks passed!"

package-lock.json

Lines changed: 905 additions & 714 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wds-bt",
3-
"version": "1.2.0",
3+
"version": "1.1.0",
44
"private": true,
55
"description": "A starter block theme from WebDevStudios.",
66
"author": "WebDevStudios <[email protected]>",
@@ -100,7 +100,7 @@
100100
"create-block": "run-s create-block:run",
101101
"create-block:run": "cd ./assets/blocks && npx @wordpress/create-block --namespace=wdsbt --template ../../inc/block-template --no-plugin",
102102
"format": "wp-scripts format && npm run format:php",
103-
"format:css": "wp-scripts format ./assets/**/*.scss",
103+
"format:css": "wp-scripts format '**/*.scss'",
104104
"format:php": "composer run-script phpcs-fix",
105105
"lint": "run-p lint:*",
106106
"lint:css": "wp-scripts lint-style",

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: webdevstudios, khleomix, bgardner
33
Requires at least: 6.4
44
Tested up to: 6.4
55
Requires PHP: 8.2
6-
Stable tag: 0.1.0
6+
Stable tag: 1.1.0
77
License: GPLv3
88
License URI: https://www.gnu.org/licenses/gpl-3.0.html
99

updateVersion.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ if (!version) {
88
process.exit(1);
99
}
1010

11-
const updateJsonFile = (filePath) => {
11+
const updateJsonFile = (filePath, label = filePath) => {
1212
if (!fs.existsSync(filePath)) {
1313
return;
1414
}
1515

1616
const jsonData = JSON.parse(fs.readFileSync(filePath, 'utf8'));
1717

1818
if (jsonData.version === version) {
19-
console.log(
20-
`No update needed for ${filePath} (already version ${version}).`
21-
);
19+
console.log(`No update needed for ${label} (already version ${version}).`);
2220
return;
2321
}
2422

@@ -28,36 +26,37 @@ const updateJsonFile = (filePath) => {
2826
JSON.stringify(jsonData, null, 2) + '\n',
2927
'utf8'
3028
);
31-
console.log(`Updated version in ${filePath} to ${version}`);
29+
console.log(`Updated version in ${label} to ${version}`);
3230
};
3331

34-
const updateTextFile = (filePath, regex, replacement) => {
32+
const updateTextFile = (filePath, regex, replacement, label = filePath) => {
3533
if (!fs.existsSync(filePath)) {
3634
return;
3735
}
3836

3937
let fileContent = fs.readFileSync(filePath, 'utf8');
38+
const match = fileContent.match(regex);
39+
40+
if (match) {
41+
const currentVersion = match[2];
42+
if (currentVersion === version) {
43+
console.log(`No update needed for ${label} (already version ${version}).`);
44+
return;
45+
}
4046

41-
if (regex.test(fileContent)) {
4247
fileContent = fileContent.replace(regex, replacement);
4348
fs.writeFileSync(filePath, fileContent, 'utf8');
44-
console.log(`Updated version in ${filePath} to ${version}`);
49+
console.log(`Updated version in ${label} to ${version}`);
4550
} else {
46-
console.warn(
47-
`Version pattern not found in ${filePath}, skipping update.`
48-
);
51+
console.warn(`Version pattern not found in ${label}, skipping update.`);
4952
}
5053
};
5154

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

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

0 commit comments

Comments
 (0)