@pugpigjs/create-wp-project 0.0.2-beta.1 → 0.0.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @pugpigjs/create-wp-project
2
2
 
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - c2f5db8: Initial release of CLI tool for scaffolding WordPress plugins and themes with interactive prompts, case-insensitive placeholder replacement, and commands for initialising, adding, removing, and updating projects from template repositories.
8
+ - 13f211a: Add --branch option and shorthand flags (-g, -d, -t, -b) to CLI for easier command usage.
9
+ - 3809018: Add environment variable support (PUGPIG_WORDPRESS_TEMPLATE_REPO_URL) and shorthand CLI flags (-g, -d, -t, -b) for improved developer experience.
10
+
11
+ ## 0.0.2-beta.2
12
+
13
+ ### Patch Changes
14
+
15
+ - 3809018: Add environment variable support (PUGPIG_WORDPRESS_TEMPLATE_REPO_URL) and shorthand CLI flags (-g, -d, -t, -b) for improved developer experience.
16
+
3
17
  ## 0.0.2-beta.1
4
18
 
5
19
  ### 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
- npx @pugpigjs/create-wp-project init --git-url <repository-url> --directory <target-directory>
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
- - `TPL_NAMESPACE` / `tpl_namespace` - Namespace in PascalCase (e.g., "Pugpig")
30
- - `TPL_NAMESPACE_LOWER` / `tpl_namespace_lower` - Lowercase namespace (e.g., "pugpig")
31
- - `TPL_PROJECT_NAME` / `tpl_project_name` - Project name in snake_case (e.g., "my_plugin")
32
- - `TPL_PROJECT_NAME_PASCAL` / `tpl_project_name_pascal` - PascalCase name (e.g., "MyPlugin")
33
- - `TPL_PROJECT_NAME_SLUG` / `tpl_project_name_slug` - Kebab-case for NPM/URLs (e.g., "my-plugin")
34
- - `TPL_PROJECT_NAME_FLAT` / `tpl_project_name_flat` - No separators (e.g., "myplugin")
35
- - `TPL_FULL_PROJECT_NAME` / `tpl_full_project_name` - Full project name with namespace (e.g., "pugpig_my_plugin")
36
- - `TPL_FULL_PROJECT_NAME_SLUG` / `tpl_full_project_name_slug` - Kebab-case full name (e.g., "pugpig-my-plugin")
37
- - `TPL_FULL_PROJECT_NAME_TITLE` / `tpl_full_project_name_title` - Title Case full name (e.g., "Pugpig My Plugin")
38
- - `TPL_FULL_PROJECT_NAME_UPPER` / `tpl_full_project_name_upper` - For plugin/theme headers (e.g., "PUGPIG MY PLUGIN")
39
- - `TPL_DESCRIPTION` / `tpl_description` - Human-readable description
40
- - `pkg_*` (wildcard) - Any package name starting with `pkg_` gets replaced with the full project name slug (e.g., `pkg_example_theme` → `pugpig-my-theme`)
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
- npx @pugpigjs/create-wp-project init --git-url <repository-url> --directory <target-directory>
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
- npx @pugpigjs/create-wp-project add --git-url <repository-url> --directory <target-directory>
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
- npx @pugpigjs/create-wp-project remove --directory <target-directory>
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
- npx @pugpigjs/create-wp-project update --git-url <repository-url> --directory <target-directory>
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>` - **(Required)** Git repository URL or local path to the template
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
- npx @pugpigjs/create-wp-project init \
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
- npx @pugpigjs/create-wp-project init -g . -d ./test-server
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
- npx @pugpigjs/create-wp-project init \
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
- npx @pugpigjs/create-wp-project add \
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
- npx @pugpigjs/create-wp-project update \
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 14 or higher
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
- ### Rich Plugin
201
- Full-featured plugin with Vue.js, SCSS, and advanced build setup. Includes:
202
- - Vite build system with HMR support
203
- - Vue.js components
204
- - SCSS preprocessing
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pugpigjs/create-wp-project",
3
- "version": "0.0.2-beta.1",
3
+ "version": "0.0.2",
4
4
  "description": "CLI tool to scaffold WordPress plugins and themes from a template repo.",
5
5
  "type": "module",
6
6
  "bin": {
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
- .requiredOption('-g, --git-url <url>', 'Git repository URL or local path to template')
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
- .requiredOption('-g, --git-url <url>', 'Git repository URL or local path to template')
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
- .requiredOption('-g, --git-url <url>', 'Git repository URL or local path to template')
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)
@@ -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://') &&