@bootmap/wpep-cli 1.0.2 → 1.0.5

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.5",
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,7 +56,29 @@ export default async function deployCommand(options) {
57
56
  }
58
57
  }
59
58
 
59
+ let outputDir = options.dir || 'wpep-build';
60
+ const targetDir = path.join(process.cwd(), 'wpep-build');
61
+
62
+ if (!fs.existsSync(targetDir)) {
63
+ // Try to auto-detect and move/copy to wpep-build
64
+ const possibleDirs = ['out', 'dist', 'build'];
65
+ let foundDir = null;
66
+ for (const d of possibleDirs) {
67
+ if (fs.existsSync(path.join(process.cwd(), d))) {
68
+ foundDir = d;
69
+ break;
70
+ }
71
+ }
72
+
73
+ if (foundDir) {
74
+ console.log(chalk.gray(`Auto-detected build in "${foundDir}". Copying to "wpep-build"...`));
75
+ fs.cpSync(path.join(process.cwd(), foundDir), targetDir, { recursive: true });
76
+ }
77
+ }
78
+
79
+ outputDir = 'wpep-build';
60
80
  const outDir = path.join(process.cwd(), outputDir);
81
+
61
82
  if (!fs.existsSync(outDir)) {
62
83
  throw new Error(`Export directory "${outputDir}" does not exist. Did the build succeed?`);
63
84
  }
@@ -71,7 +92,7 @@ export default async function deployCommand(options) {
71
92
  const data = fs.readFileSync(file);
72
93
  filesList[relativePath] = crypto.createHash('sha256').update(data).digest('hex');
73
94
  }
74
-
95
+
75
96
  spinner.text = `Creating deployment session for ${allFiles.length} files...`;
76
97
 
77
98
  let deployId;
@@ -81,14 +102,14 @@ export default async function deployCommand(options) {
81
102
  headers: { 'Content-Type': 'application/json', 'x-wpep-api-key': key },
82
103
  body: JSON.stringify({ files: filesList })
83
104
  });
84
-
105
+
85
106
  if (!createRes.ok) {
86
107
  throw new Error(`Server returned ${createRes.status} ${createRes.statusText}`);
87
108
  }
88
-
109
+
89
110
  const createData = await createRes.json();
90
111
  if (!createData.deployment_id) {
91
- throw new Error(`Invalid response from server: ${JSON.stringify(createData)}`);
112
+ throw new Error(`Invalid response from server: ${JSON.stringify(createData)}`);
92
113
  }
93
114
  deployId = createData.deployment_id;
94
115
  } catch (e) {
@@ -107,7 +128,7 @@ export default async function deployCommand(options) {
107
128
  const hash = filesList[relativePath];
108
129
 
109
130
  const uploadSpinner = ora(`Uploading ${relativePath}...`).start();
110
-
131
+
111
132
  try {
112
133
  const uploadRes = await fetch(`${url}/wp-json/wpep/v1/deployments/${deployId}/upload`, {
113
134
  method: 'POST',
@@ -132,7 +153,7 @@ export default async function deployCommand(options) {
132
153
  headers: { 'Content-Type': 'application/json', 'x-wpep-api-key': key }
133
154
  });
134
155
  if (!activateRes.ok) {
135
- throw new Error(`Activation failed: ${activateRes.statusText}`);
156
+ throw new Error(`Activation failed: ${activateRes.statusText}`);
136
157
  }
137
158
  activateSpinner.succeed('Deployment activated successfully!');
138
159
  } catch (e) {