@bootmap/wpep-cli 1.0.8 → 1.0.9

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.8",
3
+ "version": "1.0.9",
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",
@@ -101,23 +101,26 @@ export default async function deployCommand(options) {
101
101
  let outputDir = options.dir || 'wpep-build';
102
102
  const targetDir = path.join(process.cwd(), 'wpep-build');
103
103
 
104
- if (!fs.existsSync(targetDir)) {
105
- // Try to auto-detect and copy to wpep-build
106
- const possibleDirs = ['out', 'dist', 'build'];
107
- let foundDir = null;
108
- for (const d of possibleDirs) {
109
- if (fs.existsSync(path.join(process.cwd(), d))) {
110
- foundDir = d;
111
- break;
112
- }
113
- }
104
+ // Always clear previous wpep-build so we deploy fresh output
105
+ if (fs.existsSync(targetDir)) {
106
+ fs.rmSync(targetDir, { recursive: true, force: true });
107
+ }
114
108
 
115
- if (foundDir) {
116
- console.log(chalk.gray(`Auto-detected build in "${foundDir}". Copying to "wpep-build"...`));
117
- fs.cpSync(path.join(process.cwd(), foundDir), targetDir, { recursive: true });
109
+ // Auto-detect build output and copy to wpep-build
110
+ const possibleDirs = ['out', 'dist', 'build'];
111
+ let foundDir = null;
112
+ for (const d of possibleDirs) {
113
+ if (fs.existsSync(path.join(process.cwd(), d))) {
114
+ foundDir = d;
115
+ break;
118
116
  }
119
117
  }
120
118
 
119
+ if (foundDir) {
120
+ console.log(chalk.gray(`Auto-detected build in "${foundDir}". Copying to "wpep-build"...`));
121
+ fs.cpSync(path.join(process.cwd(), foundDir), targetDir, { recursive: true });
122
+ }
123
+
121
124
  outputDir = 'wpep-build';
122
125
  const outDir = path.join(process.cwd(), outputDir);
123
126
 
@@ -138,6 +141,7 @@ export default async function deployCommand(options) {
138
141
  spinner.text = `Creating deployment session for ${allFiles.length} files...`;
139
142
 
140
143
  let deployId;
144
+ let remoteManifest = null;
141
145
  try {
142
146
  const createRes = await fetch(`${url}/wp-json/wpep/v1/deployments/create`, {
143
147
  method: 'POST',
@@ -154,6 +158,7 @@ export default async function deployCommand(options) {
154
158
  throw new Error(`Invalid response from server: ${JSON.stringify(createData)}`);
155
159
  }
156
160
  deployId = createData.deployment_id;
161
+ remoteManifest = createData.remote_manifest;
157
162
  } catch (e) {
158
163
  spinner.fail('Failed to create deployment session.');
159
164
  throw e;
@@ -161,9 +166,27 @@ export default async function deployCommand(options) {
161
166
 
162
167
  spinner.succeed(`Created deployment session: ${chalk.bold(deployId)}`);
163
168
 
164
- console.log(chalk.gray('\nUploading files...'));
169
+ // Build a set of unchanged files by comparing hashes with the remote manifest
170
+ const unchangedFiles = new Set();
171
+ if (remoteManifest && remoteManifest.files) {
172
+ for (const [filePath, localHash] of Object.entries(filesList)) {
173
+ const remoteMeta = remoteManifest.files[filePath];
174
+ if (remoteMeta && remoteMeta === localHash) {
175
+ unchangedFiles.add(filePath);
176
+ }
177
+ }
178
+ }
179
+
180
+ const changedFiles = allFiles.filter(f => !unchangedFiles.has(path.relative(outDir, f)));
181
+ const skippedCount = allFiles.length - changedFiles.length;
182
+
183
+ if (skippedCount > 0) {
184
+ console.log(chalk.green(`\n⚔ ${skippedCount} unchanged files will be copied server-side (not re-uploaded).`));
185
+ }
186
+ console.log(chalk.gray(`Uploading ${changedFiles.length} changed files...\n`));
187
+
165
188
  let uploaded = 0;
166
- for (const file of allFiles) {
189
+ for (const file of changedFiles) {
167
190
  const relativePath = path.relative(outDir, file);
168
191
  const data = fs.readFileSync(file);
169
192
  const base64Data = data.toString('base64');
@@ -203,5 +226,6 @@ export default async function deployCommand(options) {
203
226
  throw e;
204
227
  }
205
228
 
206
- console.log(chalk.green.bold(`\nšŸŽ‰ Success! Your site is live at ${url}\n`));
229
+ console.log(chalk.green.bold(`\nšŸŽ‰ Success! Your site is live at ${url}`));
230
+ console.log(chalk.gray(` ${uploaded} files uploaded, ${skippedCount} files copied from previous deployment.\n`));
207
231
  }