@bootmap/wpep-cli 1.0.9 → 1.1.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/bin/wpep.js CHANGED
@@ -3,12 +3,13 @@ import { Command } from 'commander';
3
3
  import chalk from 'chalk';
4
4
  import initCommand from '../src/commands/init.js';
5
5
  import deployCommand from '../src/commands/deploy.js';
6
+ import githubCommand from '../src/commands/github.js';
6
7
 
7
8
  const program = new Command();
8
9
 
9
10
  program
10
11
  .name('wpep')
11
- .description('Deploy Next.js static exports to WordPress via WP Elementor Publisher')
12
+ .description('Deploy static sites (Next.js, Astro, React) to WordPress via WPEP')
12
13
  .version('1.0.0');
13
14
 
14
15
  program
@@ -39,6 +40,18 @@ program
39
40
  }
40
41
  });
41
42
 
43
+ program
44
+ .command('github')
45
+ .description('Generate a GitHub Actions workflow for auto-deploy on git push')
46
+ .action(async () => {
47
+ try {
48
+ await githubCommand();
49
+ } catch (err) {
50
+ console.error(chalk.red(`Error: ${err.message}`));
51
+ process.exit(1);
52
+ }
53
+ });
54
+
42
55
  program.parse(process.argv);
43
56
 
44
57
  if (!process.argv.slice(2).length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bootmap/wpep-cli",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool for deploying Next.js static exports to WordPress via WP Elementor Publisher",
5
5
  "main": "bin/wpep.js",
6
6
  "type": "module",
@@ -0,0 +1,68 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import chalk from 'chalk';
4
+
5
+ const WORKFLOW_TEMPLATE = `name: Deploy to WordPress (WPEP)
6
+
7
+ on:
8
+ push:
9
+ branches: [main]
10
+
11
+ jobs:
12
+ deploy:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '20'
20
+ cache: 'npm'
21
+
22
+ - name: Install dependencies
23
+ run: npm ci
24
+
25
+ - name: Deploy to WordPress
26
+ run: npx @bootmap/wpep-cli deploy --url \${{ secrets.WPEP_URL }} --key \${{ secrets.WPEP_API_KEY }}
27
+ `;
28
+
29
+ export default async function githubCommand() {
30
+ const cwd = process.cwd();
31
+ const workflowDir = path.join(cwd, '.github', 'workflows');
32
+ const workflowPath = path.join(workflowDir, 'wpep-deploy.yml');
33
+
34
+ // Create .github/workflows if it doesn't exist
35
+ if (!fs.existsSync(workflowDir)) {
36
+ fs.mkdirSync(workflowDir, { recursive: true });
37
+ }
38
+
39
+ // Write the workflow file
40
+ fs.writeFileSync(workflowPath, WORKFLOW_TEMPLATE, 'utf8');
41
+
42
+ // Read .wpeprc.json to show the user their URL
43
+ let siteUrl = 'https://your-site.com';
44
+ const rcPath = path.join(cwd, '.wpeprc.json');
45
+ if (fs.existsSync(rcPath)) {
46
+ try {
47
+ const config = JSON.parse(fs.readFileSync(rcPath, 'utf8'));
48
+ if (config.url) siteUrl = config.url;
49
+ } catch (e) { /* ignore */ }
50
+ }
51
+
52
+ console.log(chalk.green.bold('\nāœ… GitHub Actions workflow created!\n'));
53
+ console.log(chalk.gray(` File: .github/workflows/wpep-deploy.yml\n`));
54
+
55
+ console.log(chalk.yellow.bold('šŸ“‹ Next steps:\n'));
56
+ console.log(chalk.white('1. Go to your GitHub repo → Settings → Secrets and variables → Actions'));
57
+ console.log(chalk.white('2. Add these two repository secrets:\n'));
58
+
59
+ console.log(chalk.cyan(' WPEP_URL') + chalk.gray(` → ${siteUrl}`));
60
+ console.log(chalk.cyan(' WPEP_API_KEY') + chalk.gray(` → (copy from WordPress → WPEP → Settings)\n`));
61
+
62
+ console.log(chalk.white('3. Push to the ') + chalk.green('main') + chalk.white(' branch:\n'));
63
+ console.log(chalk.gray(' git add .'));
64
+ console.log(chalk.gray(' git commit -m "Add WPEP auto-deploy"'));
65
+ console.log(chalk.gray(' git push origin main\n'));
66
+
67
+ console.log(chalk.green.bold('šŸš€ After that, every push to main will auto-deploy to WordPress!\n'));
68
+ }