@pitcher/cli-scripts 2.1.0 → 2.1.1

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.
@@ -61,6 +61,7 @@ async function syncToApi(distPath, org, appName, fileId, apiKey) {
61
61
  headers: {
62
62
  "x-api-key": apiKey,
63
63
  ...formData.getHeaders(),
64
+ "Content-Length": formData.getLengthSync(),
64
65
  },
65
66
  maxBodyLength: Infinity,
66
67
  maxContentLength: Infinity,
@@ -155,7 +156,10 @@ export function createDevSyncCommand() {
155
156
  console.log("");
156
157
  let syncTimeout = null;
157
158
  let isSyncing = false;
159
+ let isShuttingDown = false;
158
160
  const doSync = async () => {
161
+ if (isShuttingDown)
162
+ return;
159
163
  if (isSyncing) {
160
164
  console.log("ā³ Sync already in progress, queuing...");
161
165
  syncTimeout = setTimeout(doSync, debounceMs);
@@ -192,13 +196,23 @@ export function createDevSyncCommand() {
192
196
  console.log(`šŸ“ Change detected: ${path.relative(distPath, filePath)}`);
193
197
  syncTimeout = setTimeout(doSync, debounceMs);
194
198
  });
195
- // Initial sync
196
- console.log("šŸš€ Initial sync...");
197
- await doSync();
198
- // Graceful shutdown - revert dev override
199
+ // Graceful shutdown - revert dev override (register before initial sync)
199
200
  const shutdown = async (signal) => {
200
- console.log(`\nšŸ‘‹ ${signal} received, reverting dev override...`);
201
+ if (isShuttingDown)
202
+ return;
203
+ isShuttingDown = true;
204
+ console.log(`\nšŸ‘‹ ${signal} received...`);
201
205
  watcher.close();
206
+ if (syncTimeout)
207
+ clearTimeout(syncTimeout);
208
+ // Wait for any in-progress sync to complete
209
+ if (isSyncing) {
210
+ console.log("ā³ Waiting for sync to complete...");
211
+ while (isSyncing) {
212
+ await new Promise((resolve) => setTimeout(resolve, 100));
213
+ }
214
+ }
215
+ console.log("šŸ”„ Reverting dev override...");
202
216
  try {
203
217
  await revertDevOverride(options.org, options.fileId, apiKey);
204
218
  }
@@ -209,6 +223,9 @@ export function createDevSyncCommand() {
209
223
  };
210
224
  process.on("SIGINT", () => shutdown("SIGINT"));
211
225
  process.on("SIGTERM", () => shutdown("SIGTERM"));
226
+ // Initial sync
227
+ console.log("šŸš€ Initial sync...");
228
+ await doSync();
212
229
  });
213
230
  program
214
231
  .command("revert")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pitcher/cli-scripts",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "The Pitcher CLI for various tasks in its ecosystem.",
5
5
  "author": "Pitcher AG",
6
6
  "license": "MIT",