wp-uikit-cli 1.0.0
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.
- package/LICENSE +5 -0
- package/README.md +330 -0
- package/index.js +1024 -0
- package/package.json +43 -0
- package/stubs/script.js.stub +1 -0
- package/stubs/style.css.stub +4 -0
- package/stubs/trait.php.stub +12 -0
- package/stubs/widget.php.stub +100 -0
- package/traits.json +22 -0
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# โก WP-UIkit CLI
|
|
4
|
+
|
|
5
|
+
**Scaffold. Debug. Clean. Deploy.**
|
|
6
|
+
A blazing-fast command-line toolkit for building **SF Framework** & **SF Widget** (Elementor) plugin widgets and traits โ in seconds, not minutes.
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/wp-uikit-cli)
|
|
9
|
+
[](https://www.npmjs.com/package/wp-uikit-cli)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
[](https://nodejs.org)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ๐ Table of Contents
|
|
18
|
+
|
|
19
|
+
- [โจ Features](#-features)
|
|
20
|
+
- [๐ฆ Installation](#-installation)
|
|
21
|
+
- [๐ Quick Start](#-quick-start)
|
|
22
|
+
- [๐งญ Commands](#-commands)
|
|
23
|
+
- [`sf create`](#-sf-create)
|
|
24
|
+
- [`sf clean`](#-sf-clean)
|
|
25
|
+
- [`sf debug`](#-sf-debug)
|
|
26
|
+
- [`sf deploy`](#-sf-deploy)
|
|
27
|
+
- [`sf zip`](#-sf-zip)
|
|
28
|
+
- [๐งฉ Traits System](#-traits-system)
|
|
29
|
+
- [๐ Generated File Structure](#-generated-file-structure)
|
|
30
|
+
- [โ๏ธ How It Works](#๏ธ-how-it-works)
|
|
31
|
+
- [๐ ๏ธ Requirements](#๏ธ-requirements)
|
|
32
|
+
- [โ FAQ](#-faq)
|
|
33
|
+
- [๐ค Contributing](#-contributing)
|
|
34
|
+
- [๐ License](#-license)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## โจ Features
|
|
39
|
+
|
|
40
|
+
| | Feature | Description |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| ๐งฑ | **Widget Scaffolding** | Interactively generate a fully wired Elementor widget (`.php`, `.css`, `.js`, docs) from stubs. |
|
|
43
|
+
| ๐งฉ | **Trait Scaffolding** | Create reusable PHP traits and auto-register them so widgets can consume shared controls. |
|
|
44
|
+
| ๐ | **Smart Trait Wiring** | Automatically parses trait method signatures and injects correct `use` statements + method calls into your widget class. |
|
|
45
|
+
| ๐งน | **String Localization** | `sf clean` auto-wraps raw strings in `esc_html__()` with the `sf-widget` text-domain โ for one widget or the whole project. |
|
|
46
|
+
| ๐ | **One-Line WP Debugging** | Toggle `WP_DEBUG`, `WP_DEBUG_LOG`, and `WP_DEBUG_DISPLAY` in `wp-config.php` instantly. |
|
|
47
|
+
| ๐ | **One-Command Deploy** | Minifies JS/CSS, disables dev-mode flags, strips `.gitignore`, zips the plugin, and updates `update.json` โ all in one go. |
|
|
48
|
+
| ๐ฆ | **Instant Zipping** | Package your current working directory into a distributable `.zip` archive. |
|
|
49
|
+
| โก | **Lazy-Loaded Dependencies** | Heavy libs (`adm-zip`, `terser`, `clean-css`) load on-demand โ keeping every command snappy. |
|
|
50
|
+
| ๐จ | **Beautiful CLI UX** | ASCII banners, spinners, colorized tables, and clear success/error states via `figlet`, `ora`, and `chalk`. |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ๐ฆ Installation
|
|
55
|
+
|
|
56
|
+
Install globally to use the `sf` command anywhere:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g wp-uikit-cli
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Or run it on-demand without installing:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx wp-uikit-cli create
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
> ๐ก **Tip:** Run `sf --help` anytime to see all available commands.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## ๐ Quick Start
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# 1๏ธโฃ Navigate to your plugin root (e.g. sf-widget/)
|
|
76
|
+
cd sf-widget
|
|
77
|
+
|
|
78
|
+
# 2๏ธโฃ Scaffold a new widget or trait interactively
|
|
79
|
+
sf create
|
|
80
|
+
|
|
81
|
+
# 3๏ธโฃ Localize all visible strings for WordPress i18n
|
|
82
|
+
sf clean --all
|
|
83
|
+
|
|
84
|
+
# 4๏ธโฃ Turn on WP debugging while you build
|
|
85
|
+
sf debug on
|
|
86
|
+
|
|
87
|
+
# 5๏ธโฃ Ship it ๐ข
|
|
88
|
+
sf deploy --widget
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ๐งญ Commands
|
|
94
|
+
|
|
95
|
+
### ๐งฑ `sf create`
|
|
96
|
+
|
|
97
|
+
Interactively scaffold a **Widget** or a **Trait**.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
sf create
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
You'll be walked through prompts like:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
? Widget name (e.g. Heading, Icon Box): Pricing Table
|
|
107
|
+
? Create CSS file? (Y/n)
|
|
108
|
+
? Create JS file? (y/N)
|
|
109
|
+
? Elementor icon class (e.g. eicon-star): eicon-price-table
|
|
110
|
+
? Select traits to include: (Use arrow keys, <space> to select)
|
|
111
|
+
โ ButtonTrait
|
|
112
|
+
โ HeadingTrait
|
|
113
|
+
โฏ RatingTrait
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The CLI then:
|
|
117
|
+
- โ
Generates `widgets/<slug>.php` from `widget.php.stub`
|
|
118
|
+
- โ
Optionally generates CSS/JS companions
|
|
119
|
+
- โ
Auto-detects selected traits' PHP method signatures
|
|
120
|
+
- โ
Injects correct `use` statements, `register_*_controls()`, and `render_*()` calls
|
|
121
|
+
- โ
Warns before overwriting existing files
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### ๐งน `sf clean`
|
|
126
|
+
|
|
127
|
+
Wrap raw, user-visible strings in `esc_html__()` with the `sf-widget` text domain โ a must for WordPress i18n and plugin review compliance.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
sf clean <widgetName> # Clean a single widget
|
|
131
|
+
sf clean --all # Clean every widget & print a report
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Sample output:**
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
๐ Localization Report
|
|
138
|
+
|
|
139
|
+
โ Widget โ Status โ esc_html Count โ Domain โ
|
|
140
|
+
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโค
|
|
141
|
+
โ pricing-table โ โ Done โ 12 โ sf-widget โ
|
|
142
|
+
โ testimonial โ โ Done โ 7 โ sf-widget โ
|
|
143
|
+
|
|
144
|
+
โจ Summary
|
|
145
|
+
โโ Total widgets processed: 2
|
|
146
|
+
โโ Total esc_html__() added: 19
|
|
147
|
+
โโ Domain used: sf-widget
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
It intelligently:
|
|
151
|
+
- Normalizes existing `esc_html__()` / `__()` calls to the correct domain
|
|
152
|
+
- Wraps plain `label`, `title`, `description`, `placeholder`, and `raw` strings
|
|
153
|
+
- Avoids double-wrapping already-escaped strings
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
### ๐ `sf debug`
|
|
158
|
+
|
|
159
|
+
Toggle WordPress debug mode without ever opening `wp-config.php` yourself.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
sf debug on # Enables WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY
|
|
163
|
+
sf debug off # Cleanly reverts back to production settings
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
- ๐ Automatically walks up the directory tree to locate `wp-config.php`
|
|
167
|
+
- ๐ Appends/updates the debug block safely without breaking existing config
|
|
168
|
+
- ๐ฃ Prints exactly where to check your logs (`wp-content/debug.log`)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### ๐ `sf deploy`
|
|
173
|
+
|
|
174
|
+
The **release button** for `sf-framework` and `sf-widget` plugins.
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
sf deploy --framework # Deploy the SF Framework plugin
|
|
178
|
+
sf deploy --widget # Deploy the SF Widget plugin
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
You'll be prompted for a **destination folder** and a **new version** (`X.Y.Z`), then the CLI automatically:
|
|
182
|
+
|
|
183
|
+
1. ๐๏ธ Minifies every `.js` file with **Terser** โ `*.min.js`
|
|
184
|
+
2. ๐จ Minifies every `.css` file with **CleanCSS** โ `*.min.css`
|
|
185
|
+
3. ๐ฉ Flips the dev-mode constant (`SF_DEVELOPMENT_MODE` / `SF_FRAMEWORK_DEVELOPMENT_MODE`) to `false`
|
|
186
|
+
4. ๐งน Removes `.gitignore` (and the `fonts` folder for widget builds)
|
|
187
|
+
5. ๐ฆ Zips the plugin (excluding `.git`, `node_modules`)
|
|
188
|
+
6. ๐ค Moves the zip to your destination folder
|
|
189
|
+
7. ๐ Updates `update.json` with the new version & download URL
|
|
190
|
+
8. โ
Prints a full summary + suggested git commands
|
|
191
|
+
|
|
192
|
+
**Sample output:**
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
โ Deploy complete โ sf-widget v1.4.0
|
|
196
|
+
|
|
197
|
+
Output
|
|
198
|
+
โโ Zip D:\Releases\sf-widget-1.4.0.zip
|
|
199
|
+
โโ JSON D:\Releases\update.json
|
|
200
|
+
|
|
201
|
+
Next steps
|
|
202
|
+
โโ Open the destination folder in your file manager
|
|
203
|
+
โโ Review the changes โ check update.json & zip
|
|
204
|
+
โโ Stage all changes: git add .
|
|
205
|
+
โโ Commit: git commit -m "Release sf-widget v1.4.0"
|
|
206
|
+
โโ Push: git push
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### ๐ฆ `sf zip`
|
|
212
|
+
|
|
213
|
+
Quickly zip the current working directory.
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
sf zip # Uses the current folder name as the zip name
|
|
217
|
+
sf zip my-plugin # Custom output name โ my-plugin.zip
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## ๐งฉ Traits System
|
|
223
|
+
|
|
224
|
+
Traits let you share reusable Elementor controls (buttons, ratings, badges, avatars, progress bars, etc.) across multiple widgets without duplicating code.
|
|
225
|
+
|
|
226
|
+
- Trait files live in `core/includes/traits/*-trait.php`
|
|
227
|
+
- Registered traits are tracked in [`traits.json`](./traits.json)
|
|
228
|
+
- Running `sf create` automatically **syncs** this registry by scanning your traits folder
|
|
229
|
+
- When you attach traits to a widget, the CLI **reads the trait's PHP source**, extracts its `register_*_controls()` / `render_*()` method signatures, and generates matching `use` + call-site code โ no manual wiring required
|
|
230
|
+
|
|
231
|
+
<details>
|
|
232
|
+
<summary>๐ Example traits already available in this project</summary>
|
|
233
|
+
|
|
234
|
+
`AvatarTrait` ยท `BadgeTrait` ยท `ButtonTrait` ยท `DescriptionTrait` ยท `FancyAnimatedTextTrait` ยท `HeaderTrait` ยท `HeadingTrait` ยท `HtmlSnippetTrait` ยท `ListTrait` ยท `ParagraphTrait` ยท `ProgressbarTrait` ยท `RatingTrait` ยท `RepeaterAvatarTrait` ยท `RepeaterBadgeTrait` ยท `RepeaterButtonTrait` ยท `RepeaterListTrait` ยท `RepeaterRadialProgressbarTrait` ยท ...and more
|
|
235
|
+
|
|
236
|
+
</details>
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## ๐ Generated File Structure
|
|
241
|
+
|
|
242
|
+
Running `sf create` for a widget named **"Pricing Table"** produces:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
๐ your-plugin/
|
|
246
|
+
โโโ widgets/
|
|
247
|
+
โ โโโ pricing-table.php # Widget class with traits wired in
|
|
248
|
+
โโโ assets/
|
|
249
|
+
โโโ css/
|
|
250
|
+
โ โโโ pricing-table.css
|
|
251
|
+
โโโ js/
|
|
252
|
+
โโโ pricing-table.js
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## โ๏ธ How It Works
|
|
258
|
+
|
|
259
|
+
```mermaid
|
|
260
|
+
flowchart LR
|
|
261
|
+
A[sf create] --> B{Widget or Trait?}
|
|
262
|
+
B -->|Widget| C[Prompt for name, assets, icon, traits]
|
|
263
|
+
C --> D[Parse selected trait PHP files]
|
|
264
|
+
D --> E[Inject use + register/render calls]
|
|
265
|
+
E --> F[Write from stubs/*.stub]
|
|
266
|
+
B -->|Trait| G[Prompt for trait name]
|
|
267
|
+
G --> H[Write trait.php.stub โ core/includes/traits/]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
All generated files come from customizable templates in [`stubs/`](./stubs):
|
|
271
|
+
|
|
272
|
+
| Stub | Purpose |
|
|
273
|
+
|---|---|
|
|
274
|
+
| `widget.php.stub` | Base Elementor widget class |
|
|
275
|
+
| `style.css.stub` | Widget stylesheet |
|
|
276
|
+
| `script.js.stub` | Widget frontend script |
|
|
277
|
+
| `trait.php.stub` | Reusable trait skeleton |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## ๐ ๏ธ Requirements
|
|
282
|
+
|
|
283
|
+
- **Node.js** โฅ 16
|
|
284
|
+
- A project following the **SF Framework** / **SF Widget** directory conventions (`widgets/`, `assets/`, `core/includes/traits/`)
|
|
285
|
+
- WordPress + Elementor installation for `sf debug` (looks for `wp-config.php`)
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## โ FAQ
|
|
290
|
+
|
|
291
|
+
<details>
|
|
292
|
+
<summary><strong>Does <code>sf deploy</code> modify my source files permanently?</strong></summary>
|
|
293
|
+
<br>
|
|
294
|
+
Yes โ minification replaces original <code>.js</code>/<code>.css</code> files with <code>.min.js</code>/<code>.min.css</code> in your working directory, and the dev-mode flag is flipped to <code>false</code>. Always deploy from a clean git state so you can diff/revert if needed.
|
|
295
|
+
</details>
|
|
296
|
+
|
|
297
|
+
<details>
|
|
298
|
+
<summary><strong>Why does the first command feel slightly slower the very first time?</strong></summary>
|
|
299
|
+
<br>
|
|
300
|
+
Heavy dependencies (<code>adm-zip</code>, <code>terser</code>, <code>clean-css</code>) are <strong>lazy-loaded</strong> only when a command that needs them (<code>deploy</code>, <code>zip</code>) actually runs โ keeping <code>create</code>, <code>clean</code>, and <code>debug</code> fast at all times.
|
|
301
|
+
</details>
|
|
302
|
+
|
|
303
|
+
<details>
|
|
304
|
+
<summary><strong>Can I customize the generated widget/trait templates?</strong></summary>
|
|
305
|
+
<br>
|
|
306
|
+
Yes! Edit the files in the <code>stubs/</code> directory. They support <code>{{PLACEHOLDER}}</code> tokens which are replaced at generation time.
|
|
307
|
+
</details>
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## ๐ค Contributing
|
|
312
|
+
|
|
313
|
+
Contributions, issue reports, and feature ideas are welcome!
|
|
314
|
+
|
|
315
|
+
1. Fork the repo
|
|
316
|
+
2. Create a feature branch: `git checkout -b feature/amazing-thing`
|
|
317
|
+
3. Commit your changes: `git commit -m "Add amazing thing"`
|
|
318
|
+
4. Push and open a Pull Request
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## ๐ License
|
|
323
|
+
|
|
324
|
+
Released under the **[MIT License](./LICENSE)**.
|
|
325
|
+
|
|
326
|
+
<div align="center">
|
|
327
|
+
|
|
328
|
+
Made with โค๏ธ for the **SF Framework** & **SF Widget** ecosystem.
|
|
329
|
+
|
|
330
|
+
</div>
|