Skip to content

Commit 0b653d5

Browse files
committed
Update readme and remove version update script
1 parent 278b03e commit 0b653d5

File tree

3 files changed

+7
-116
lines changed

3 files changed

+7
-116
lines changed

.github/workflows/version-update.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -542,76 +542,15 @@ WDS BT is equipped with automated workflow actions that ensure code security and
542542

543543
## Automated Versioning Process
544544

545-
This theme uses an automated versioning system that increments the `BUILD` number automatically upon merges to the `main` branch. The `VERSION` is manually controlled and is reflected in the `composer.json` and `package.json` files. The `BUILD` number is automatically appended to the `VERSION` in `style.css`.
545+
To handle cache busting for CSS and JS files, this theme automatically appends the file modification time as a version parameter to the URLs of enqueued styles and scripts, ensuring that browsers fetch the most recent version whenever the files are updated.
546546

547-
<details>
548-
<summary><strong>How It Works</strong></summary>
549-
550-
1. **VERSION**: Manually set in the `.env` file. This is reflected in the `composer.json` and `package.json` files.
551-
- Format: `X.Y.Z` (Semantic Versioning)
552-
- This value is manually updated by the developer.
553-
554-
2. **BUILD**: Automatically increments on merges to the `main` branch. This is appended to the `VERSION` in the `style.css` file.
555-
- Format: `1.0.0x` where `x` is the build number.
556-
557-
</details>
558-
559-
<details>
560-
<summary><strong>Example</strong></summary>
561-
562-
Suppose the `.env` file has the following values:
563-
564-
```plaintext
565-
VERSION=1.0.0
566-
BUILD=4
567-
```
568-
569-
After merging a PR into the `main` branch:
570-
571-
- The `BUILD` increments to `5`.
572-
- The version in `style.css` becomes `Version: 1.0.005`.
573-
- The `composer.json` and `package.json` will still reflect `1.0.0`.
574-
575-
</details>
576-
577-
<details>
578-
<summary><strong>Modifying the Version</strong></summary>
579-
580-
- To update the `VERSION`, manually edit the `.env` file:
581-
```plaintext
582-
VERSION=1.1.0
583-
BUILD=0
584-
```
585-
- The `BUILD` should not be manually modified except for specific scenarios, such as resetting the build number after a major version change.
586-
587-
</details>
588547

589548
<details>
590-
<summary><strong>Workflow</strong></summary>
591-
592-
When a PR is merged into the `main` branch, the following occurs automatically:
593-
594-
1. The `BUILD` number increments.
595-
2. The `style.css` is updated to reflect the `VERSION + BUILD`.
596-
3. The `composer.json` and `package.json` files are updated with only the `VERSION`.
597-
4. The updated files are committed back to the `main` branch.
598-
599-
</details>
600-
601-
<details>
602-
<summary><strong>Manual Execution</strong></summary>
603-
604-
You can manually trigger the versioning process locally if necessary by running:
605-
606-
```bash
607-
npm run update-version
608-
```
609-
610-
This will:
549+
<summary><strong>How It Works</strong></summary>
611550

612-
- Increment the `BUILD` number.
613-
- Update the version in `style.css`.
614-
- Ensure `composer.json` and `package.json` reflect the correct `VERSION`.
551+
1. Hooking into the `style_loader_src` and `script_loader_src` filters, which handle the URLs of enqueued styles and scripts.
552+
2. Using the `filemtime()` function to retrieve the last modified time of the `style.css` file, appending it as the version (`ver`) parameter in the asset URLs.
553+
3. This ensures that browsers always fetch the latest version of your CSS and JS files, preventing them from serving cached versions after updates.
615554
616555
</details>
617556

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
"preinstall": "cross-env npm_config_legacy_peer_deps=false",
9393
"reset": "rm -rf node_modules vendor build blocks package-lock.json composer.lock",
9494
"setup": "npm run reset && npm i && composer i && npm run build",
95-
"start": "rm -rf build blocks && cross-env NODE_ENV=development wp-scripts start",
96-
"update-version": "node updateVersion.js"
95+
"start": "rm -rf build blocks && cross-env NODE_ENV=development wp-scripts start"
9796
},
9897
"lint-staged": {
9998
"*.js": [
@@ -106,4 +105,4 @@
106105
"wp-scripts lint-style"
107106
]
108107
}
109-
}
108+
}

0 commit comments

Comments
 (0)