@pugpigjs/create-wp-project 0.0.2-beta.1 → 0.0.2-beta.2
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/CHANGELOG.md +6 -0
- package/README.md +52 -46
- package/package.json +1 -1
- package/src/cli.js +6 -3
- package/src/utils/shared.js +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @pugpigjs/create-wp-project
|
|
2
2
|
|
|
3
|
+
## 0.0.2-beta.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3809018: Add environment variable support (PUGPIG_WORDPRESS_TEMPLATE_REPO_URL) and shorthand CLI flags (-g, -d, -t, -b) for improved developer experience.
|
|
8
|
+
|
|
3
9
|
## 0.0.2-beta.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ CLI tool to scaffold WordPress plugins and themes from a template repo.
|
|
|
7
7
|
The easiest way to scaffold a new WordPress project:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
npm create @pugpigjs/wp-project -- init --git-url <repository-url> --directory <target-directory>
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
**Note:** Both `--git-url` and `--directory` are required for all commands.
|
|
@@ -24,20 +24,25 @@ This CLI tool uses a **placeholder-based templating system** to scaffold WordPre
|
|
|
24
24
|
|
|
25
25
|
### Template Placeholders
|
|
26
26
|
|
|
27
|
-
The template uses **case-insensitive** placeholder markers throughout all files. You can use either uppercase (`TPL_*`) or lowercase (`tpl_*`) variants
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
The template uses **case-insensitive** placeholder markers throughout all files. You can use either uppercase (`TPL_*`) or lowercase (`tpl_*`) variants. For JSON files or schemas that require lowercase keys, simply use the lowercase form.
|
|
28
|
+
|
|
29
|
+
| Placeholder | Example Value | Description |
|
|
30
|
+
|----------------------------------|-------------------------------|--------------------------------------------------------------------|
|
|
31
|
+
| `TPL_NAMESPACE` | `Pugpig` | Namespace in PascalCase |
|
|
32
|
+
| `TPL_NAMESPACE_LOWER` | `pugpig` | Lowercase namespace |
|
|
33
|
+
| `TPL_PROJECT_NAME` | `my_plugin` | Project name in snake_case |
|
|
34
|
+
| `TPL_PROJECT_NAME_PASCAL` | `MyPlugin` | Project name in PascalCase |
|
|
35
|
+
| `TPL_PROJECT_NAME_SLUG` | `my-plugin` | Project name in kebab-case (for NPM/URLs) |
|
|
36
|
+
| `TPL_PROJECT_NAME_FLAT` | `myplugin` | Project name with no separators |
|
|
37
|
+
| `TPL_FULL_PROJECT_NAME` | `pugpig_my_plugin` | Full project name with namespace (snake_case) |
|
|
38
|
+
| `TPL_FULL_PROJECT_NAME_SLUG` | `pugpig-my-plugin` | Full project name in kebab-case |
|
|
39
|
+
| `TPL_FULL_PROJECT_NAME_TITLE` | `Pugpig My Plugin` | Full project name in Title Case |
|
|
40
|
+
| `TPL_FULL_PROJECT_NAME_UPPER` | `PUGPIG MY PLUGIN` | Full project name in UPPERCASE |
|
|
41
|
+
| `TPL_DESCRIPTION` | `A human-readable description`| Human-readable description |
|
|
42
|
+
| `pkg_*` (wildcard) | `pkg_example_theme` → `pugpig-my-theme` | Any package name starting with `pkg_` gets replaced with the full project name slug |
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
_Use lowercase keys for compatibility with JSON schemas or config files that require them._
|
|
41
46
|
|
|
42
47
|
**Usage Examples:**
|
|
43
48
|
```php
|
|
@@ -58,7 +63,7 @@ The CLI automatically computes all these variations from your namespace and proj
|
|
|
58
63
|
### `init` - Initialise a New Project
|
|
59
64
|
|
|
60
65
|
```bash
|
|
61
|
-
|
|
66
|
+
npm create @pugpigjs/wp-project -- init --git-url <repository-url> --directory <target-directory>
|
|
62
67
|
```
|
|
63
68
|
|
|
64
69
|
This interactive CLI will:
|
|
@@ -75,7 +80,7 @@ This interactive CLI will:
|
|
|
75
80
|
If you've already initialised a project and want to add another plugin or theme:
|
|
76
81
|
|
|
77
82
|
```bash
|
|
78
|
-
|
|
83
|
+
npm create @pugpigjs/wp-project -- add --git-url <repository-url> --directory <target-directory>
|
|
79
84
|
```
|
|
80
85
|
|
|
81
86
|
This will:
|
|
@@ -91,7 +96,7 @@ This will:
|
|
|
91
96
|
To remove a plugin or theme from your project:
|
|
92
97
|
|
|
93
98
|
```bash
|
|
94
|
-
|
|
99
|
+
npm create @pugpigjs/wp-project -- remove --directory <target-directory>
|
|
95
100
|
```
|
|
96
101
|
|
|
97
102
|
This will:
|
|
@@ -107,7 +112,7 @@ This will:
|
|
|
107
112
|
To refresh configuration files (like bitbucket-pipelines.yml, renovate.json, etc.) from the latest template:
|
|
108
113
|
|
|
109
114
|
```bash
|
|
110
|
-
|
|
115
|
+
npm create @pugpigjs/wp-project -- update --git-url <repository-url> --directory <target-directory>
|
|
111
116
|
```
|
|
112
117
|
|
|
113
118
|
This will:
|
|
@@ -127,7 +132,8 @@ This is useful when:
|
|
|
127
132
|
|
|
128
133
|
All commands (`init`, `add`, and `update`) require:
|
|
129
134
|
|
|
130
|
-
- `-g, --git-url <url>` -
|
|
135
|
+
- `-g, --git-url <url>` - Git repository URL or local path to the template
|
|
136
|
+
- **Can be set via environment variable** `PUGPIG_WORDPRESS_TEMPLATE_REPO_URL` to avoid passing it every time
|
|
131
137
|
- Example: `https://github.com/user/wp-template.git`
|
|
132
138
|
- Example: `/path/to/local/template`
|
|
133
139
|
- Example: `.` (current directory for local development)
|
|
@@ -142,24 +148,39 @@ Optional:
|
|
|
142
148
|
- `-t, --template-dir <path>` - Template source directory within the repository (defaults to `repo_template`)
|
|
143
149
|
- `-b, --branch <name>` - Git branch to clone from (defaults to `master`)
|
|
144
150
|
|
|
151
|
+
### Environment Variables
|
|
152
|
+
|
|
153
|
+
You can set the following environment variable to simplify usage:
|
|
154
|
+
|
|
155
|
+
- `PUGPIG_WORDPRESS_TEMPLATE_REPO_URL` - Default git repository URL
|
|
156
|
+
- When set, the `-g, --git-url` flag becomes optional
|
|
157
|
+
- Add to your shell config (`~/.zshrc` or `~/.bashrc`):
|
|
158
|
+
```bash
|
|
159
|
+
export PUGPIG_WORDPRESS_TEMPLATE_REPO_URL=https://github.com/your-org/your-wp-template.git
|
|
160
|
+
```
|
|
161
|
+
- After setting, you can omit the `-g` flag:
|
|
162
|
+
```bash
|
|
163
|
+
npm create @pugpigjs/wp-project -- init -d ./my-project-server
|
|
164
|
+
```
|
|
165
|
+
|
|
145
166
|
|
|
146
167
|
## Examples
|
|
147
168
|
|
|
148
169
|
### Initialise from a remote repository
|
|
149
170
|
```bash
|
|
150
|
-
|
|
171
|
+
npm create @pugpigjs/wp-project -- init \
|
|
151
172
|
-g https://github.com/your-org/your-wp-template.git \
|
|
152
173
|
-d ./my-project-server
|
|
153
174
|
```
|
|
154
175
|
|
|
155
176
|
### Initialise from a local template (for development)
|
|
156
177
|
```bash
|
|
157
|
-
|
|
178
|
+
npm create @pugpigjs/wp-project -- init -g . -d ./test-server
|
|
158
179
|
```
|
|
159
180
|
|
|
160
181
|
### Initialise from a specific branch
|
|
161
182
|
```bash
|
|
162
|
-
|
|
183
|
+
npm create @pugpigjs/wp-project -- init \
|
|
163
184
|
-g https://github.com/your-org/your-wp-template.git \
|
|
164
185
|
-d ./my-project-server \
|
|
165
186
|
-b beta
|
|
@@ -167,14 +188,14 @@ npx @pugpigjs/create-wp-project init \
|
|
|
167
188
|
|
|
168
189
|
### Add another template to existing project
|
|
169
190
|
```bash
|
|
170
|
-
|
|
191
|
+
npm create @pugpigjs/wp-project -- add \
|
|
171
192
|
-g https://github.com/your-org/your-wp-template.git \
|
|
172
193
|
-d ./my-project-server
|
|
173
194
|
```
|
|
174
195
|
|
|
175
196
|
### Update configuration files
|
|
176
197
|
```bash
|
|
177
|
-
|
|
198
|
+
npm create @pugpigjs/wp-project -- update \
|
|
178
199
|
-g https://github.com/your-org/your-wp-template.git \
|
|
179
200
|
-d ./my-project-server
|
|
180
201
|
```
|
|
@@ -192,31 +213,16 @@ This CLI tool includes multiple safety checks to prevent accidental data loss:
|
|
|
192
213
|
|
|
193
214
|
## Requirements
|
|
194
215
|
|
|
195
|
-
- Node.js
|
|
216
|
+
- Node.js 24 or higher
|
|
196
217
|
- A directory ending with `-server` (e.g., `my-project-server`)
|
|
197
218
|
|
|
198
219
|
## Template Types
|
|
199
220
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
-
|
|
205
|
-
- Composer dependencies with PHP-Scoper
|
|
206
|
-
- WordPress integration utilities
|
|
207
|
-
|
|
208
|
-
### Simple Plugin
|
|
209
|
-
Lightweight plugin with basic JavaScript and CSS. Includes:
|
|
210
|
-
- Simple Vite build setup
|
|
211
|
-
- Vanilla JavaScript
|
|
212
|
-
- Basic CSS
|
|
213
|
-
- Minimal dependencies
|
|
214
|
-
|
|
215
|
-
### Theme
|
|
216
|
-
WordPress theme with modern build tooling. Includes:
|
|
217
|
-
- Vite build system
|
|
218
|
-
- Modern CSS/JS compilation
|
|
219
|
-
- Theme template structure
|
|
221
|
+
* `Rich Plugin`: A full-featured plugin template with Vue.js, SCSS, and an advanced build setup. Includes Vite build system with hot module replacement (HMR), Vue.js component support, SCSS preprocessing, Composer dependencies managed with PHP-Scoper, and utilities for seamless WordPress integration.
|
|
222
|
+
|
|
223
|
+
* `Simple Plugin`: A lightweight plugin template with a simple Vite build setup, vanilla JavaScript, basic CSS, and minimal dependencies.
|
|
224
|
+
|
|
225
|
+
* `Theme`: A WordPress theme template with a modern Vite-based build system, supporting modern CSS/JS compilation and a standard theme template structure.
|
|
220
226
|
|
|
221
227
|
## Development
|
|
222
228
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -8,6 +8,9 @@ import { updateProject } from './commands/update.js'
|
|
|
8
8
|
|
|
9
9
|
const program = new Command()
|
|
10
10
|
|
|
11
|
+
// Get default git URL from environment variable if set
|
|
12
|
+
const defaultGitUrl = process.env.PUGPIG_WORDPRESS_TEMPLATE_REPO_URL
|
|
13
|
+
|
|
11
14
|
program
|
|
12
15
|
.name('create-wp-project')
|
|
13
16
|
.description('CLI tool to scaffold WordPress plugins and themes from a template repo.')
|
|
@@ -17,7 +20,7 @@ program
|
|
|
17
20
|
.command('init')
|
|
18
21
|
.description('Initialise a new WordPress project from the template')
|
|
19
22
|
.requiredOption('-d, --directory <path>', 'Target directory (must end with -server)')
|
|
20
|
-
.
|
|
23
|
+
.option('-g, --git-url <url>', 'Git repository URL or local path to template', defaultGitUrl)
|
|
21
24
|
.option('-t, --template-dir <path>', 'Template source directory', 'repo_template')
|
|
22
25
|
.option('-b, --branch <name>', 'Git branch to clone from', 'master')
|
|
23
26
|
.action(initProject)
|
|
@@ -26,7 +29,7 @@ program
|
|
|
26
29
|
.command('add')
|
|
27
30
|
.description('Add another plugin or theme to an existing project')
|
|
28
31
|
.requiredOption('-d, --directory <path>', 'Project directory (must end with -server)')
|
|
29
|
-
.
|
|
32
|
+
.option('-g, --git-url <url>', 'Git repository URL or local path to template', defaultGitUrl)
|
|
30
33
|
.option('-t, --template-dir <path>', 'Template source directory', 'repo_template')
|
|
31
34
|
.option('-b, --branch <name>', 'Git branch to clone from', 'master')
|
|
32
35
|
.action(addTemplate)
|
|
@@ -41,7 +44,7 @@ program
|
|
|
41
44
|
.command('update')
|
|
42
45
|
.description('Update root configuration files from the template')
|
|
43
46
|
.requiredOption('-d, --directory <path>', 'Project directory (must end with -server)')
|
|
44
|
-
.
|
|
47
|
+
.option('-g, --git-url <url>', 'Git repository URL or local path to template', defaultGitUrl)
|
|
45
48
|
.option('-t, --template-dir <path>', 'Template source directory', 'repo_template')
|
|
46
49
|
.option('-b, --branch <name>', 'Git branch to clone from', 'master')
|
|
47
50
|
.action(updateProject)
|
package/src/utils/shared.js
CHANGED
|
@@ -119,6 +119,13 @@ export const prompts = {
|
|
|
119
119
|
* @param {string} branch - Git branch to clone (optional, defaults to remote's default branch)
|
|
120
120
|
*/
|
|
121
121
|
export async function cloneRepo(gitUrlOrPath, tempDir, branch = null) {
|
|
122
|
+
// Validate git URL is provided
|
|
123
|
+
if (!gitUrlOrPath) {
|
|
124
|
+
console.error(chalk.red('\n❌ Error: --git-url is required'))
|
|
125
|
+
console.error(chalk.yellow('Set PUGPIG_WORDPRESS_TEMPLATE_REPO_URL environment variable or provide --git-url flag'))
|
|
126
|
+
process.exit(1)
|
|
127
|
+
}
|
|
128
|
+
|
|
122
129
|
// Check if it's a local path
|
|
123
130
|
const isLocalPath = !gitUrlOrPath.startsWith('http://') &&
|
|
124
131
|
!gitUrlOrPath.startsWith('https://') &&
|