@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.
- package/dist/src/devSync.js +22 -5
- package/package.json +1 -1
package/dist/src/devSync.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
-
|
|
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")
|