@bootmap/wpep-cli 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bootmap/wpep-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",
@@ -4,6 +4,7 @@ import crypto from 'crypto';
4
4
  import chalk from 'chalk';
5
5
  import ora from 'ora';
6
6
  import { execSync } from 'child_process';
7
+ import inquirer from 'inquirer';
7
8
 
8
9
  function getFiles(dir, files = []) {
9
10
  if (!fs.existsSync(dir)) return files;
@@ -37,8 +38,6 @@ export default async function deployCommand(options) {
37
38
  }
38
39
  }
39
40
 
40
- const outputDir = options.dir || 'out';
41
-
42
41
  if (!url || !key) {
43
42
  throw new Error('Missing WordPress URL or API Key. Run "wpep init" or provide --url and --key arguments.');
44
43
  }
@@ -57,6 +56,36 @@ export default async function deployCommand(options) {
57
56
  }
58
57
  }
59
58
 
59
+ let outputDir = options.dir;
60
+
61
+ if (!outputDir) {
62
+ const possibleDirs = ['out', 'dist', 'build'];
63
+ const existingDirs = possibleDirs.filter(d => fs.existsSync(path.join(process.cwd(), d)));
64
+
65
+ if (existingDirs.length === 1) {
66
+ outputDir = existingDirs[0];
67
+ console.log(chalk.gray(`Auto-detected export directory: ${outputDir}`));
68
+ } else if (existingDirs.length > 1) {
69
+ const answers = await inquirer.prompt([
70
+ {
71
+ type: 'list',
72
+ name: 'dir',
73
+ message: 'Multiple export directories found. Which one do you want to deploy?',
74
+ choices: existingDirs
75
+ }
76
+ ]);
77
+ outputDir = answers.dir;
78
+ } else {
79
+ outputDir = 'out'; // fallback
80
+ }
81
+ }
82
+
83
+ if (outputDir === '.next') {
84
+ console.log(chalk.yellow.bold('\n⚠️ WARNING: You are trying to deploy the ".next" directory.'));
85
+ console.log(chalk.yellow('This contains Node.js server files, not static HTML.'));
86
+ console.log(chalk.yellow('WPEP only hosts static HTML. Please add { output: "export" } to your next.config.ts/js to generate an "out" directory instead.\n'));
87
+ }
88
+
60
89
  const outDir = path.join(process.cwd(), outputDir);
61
90
  if (!fs.existsSync(outDir)) {
62
91
  throw new Error(`Export directory "${outputDir}" does not exist. Did the build succeed?`);