@artemsemkin/wp-headers 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +26 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@ npm install @artemsemkin/wp-headers
10
10
 
11
11
  ## What it does
12
12
 
13
- Reads `wp.theme` or `wp.plugin` fields from a `package.json` and writes properly formatted WordPress header comments to the corresponding files (`style.css`, plugin PHP, `readme.txt`). Also patches version strings in TGM-style plugin arrays.
13
+ Reads `wp.theme` or `wp.plugin` fields from a `package.json` and generates or updates WordPress header comments in target files (`style.css`, plugin PHP, `readme.txt`). If a file already contains a header comment, it replaces it in place. If not, it writes a new one. Also patches version strings in TGM-style PHP plugin arrays.
14
14
 
15
15
  ## Examples
16
16
 
@@ -85,7 +85,7 @@ Given this in your plugin's `package.json`:
85
85
  }
86
86
  ```
87
87
 
88
- Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path/to/plugin' })` generates this at the top of `flavor-core.php`:
88
+ Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path/to/plugin' })` generates or updates the header at the top of `flavor-core.php`:
89
89
 
90
90
  ```php
91
91
  /**
@@ -103,6 +103,28 @@ Running `processMapping({ type: 'plugin', slug: 'flavor-core', entityDir: '/path
103
103
  */
104
104
  ```
105
105
 
106
+ ### TGM version patching
107
+
108
+ When a plugin's `package.json` includes `wp.plugin.loadPluginsFile`, the tool also patches version strings inside TGM-style PHP arrays. Given this PHP file registered via `tgmBasePath`:
109
+
110
+ ```php
111
+ $plugins = array(
112
+ array(
113
+ 'name' => 'Flavor Core',
114
+ 'slug' => 'flavor-core',
115
+ 'version' => '1.0.0',
116
+ ),
117
+ );
118
+ ```
119
+
120
+ After processing with `version: "2.0.0"` in `package.json`, the version field is updated in place:
121
+
122
+ ```php
123
+ 'version' => '2.0.0',
124
+ ```
125
+
126
+ Whitespace alignment, quote styles, and other entries are preserved.
127
+
106
128
  ## Usage
107
129
 
108
130
  ```ts
@@ -112,10 +134,10 @@ processMapping({
112
134
  type: 'plugin',
113
135
  slug: 'my-plugin',
114
136
  entityDir: '/path/to/plugin',
115
- tgmBasePath: '/path/to/theme/src/php', // optional: patches TGM version arrays
137
+ tgmBasePath: '/path/to/theme/src/php',
116
138
  })
117
139
  ```
118
140
 
119
141
  ## Vite integration
120
142
 
121
- Use [`@artemsemkin/vite-plugin-wp-headers`](https://github.com/artkrsk/vite-plugin-wp-headers) to run header generation during Vite's build lifecycle and watch for changes during dev.
143
+ Use [`@artemsemkin/vite-plugin-wp-headers`](https://www.npmjs.com/package/@artemsemkin/vite-plugin-wp-headers) to automate header generation during Vite's build lifecycle and watch for changes during dev.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artemsemkin/wp-headers",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Generate and patch WordPress file headers (style.css, plugin PHP, readme.txt, TGM)",
5
5
  "license": "MIT",
6
6
  "author": "Artem Semkin",