nstantpage-agent 0.5.13 → 0.5.14
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/commands/start.js +1 -1
- package/dist/localServer.js +23 -2
- package/package.json +1 -1
package/dist/commands/start.js
CHANGED
|
@@ -25,7 +25,7 @@ import { TunnelClient } from '../tunnel.js';
|
|
|
25
25
|
import { LocalServer } from '../localServer.js';
|
|
26
26
|
import { PackageInstaller } from '../packageInstaller.js';
|
|
27
27
|
import { probeLocalPostgres, ensureLocalProjectDb, closeAdminPool, writeDatabaseUrlToEnv } from '../projectDb.js';
|
|
28
|
-
const VERSION = '0.5.
|
|
28
|
+
const VERSION = '0.5.14';
|
|
29
29
|
/**
|
|
30
30
|
* Resolve the backend API base URL.
|
|
31
31
|
* - If --backend is passed, use it
|
package/dist/localServer.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import http from 'http';
|
|
16
16
|
import fs from 'fs';
|
|
17
|
+
import path from 'path';
|
|
17
18
|
import os from 'os';
|
|
18
19
|
import { createRequire } from 'module';
|
|
19
20
|
import { spawn } from 'child_process';
|
|
@@ -744,8 +745,28 @@ export class LocalServer {
|
|
|
744
745
|
// ─── /live/dev/restart ───────────────────────────────────────
|
|
745
746
|
async handleDevRestart(_req, res) {
|
|
746
747
|
try {
|
|
747
|
-
|
|
748
|
-
|
|
748
|
+
// Full recovery: stop dev server, ensure deps installed, ensure DB, restart
|
|
749
|
+
console.log(' [LocalServer] Full dev server restart with recovery...');
|
|
750
|
+
// 1. Stop dev server
|
|
751
|
+
await this.devServer.stop();
|
|
752
|
+
// 2. Check if project dir has files (could be wiped)
|
|
753
|
+
const pkgPath = path.join(this.options.projectDir, 'package.json');
|
|
754
|
+
if (!fs.existsSync(pkgPath)) {
|
|
755
|
+
console.log(' [LocalServer] ⚠ package.json missing — project files may have been deleted');
|
|
756
|
+
// Can't install deps without package.json —the .NET backend /restart-dev-server
|
|
757
|
+
// should have already synced files before calling us. If files still missing, error out.
|
|
758
|
+
res.statusCode = 500;
|
|
759
|
+
this.json(res, { success: false, error: 'Project files missing (no package.json). Sync files first.' });
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
// 3. Ensure database is provisioned
|
|
763
|
+
await this.ensureDatabase();
|
|
764
|
+
// 4. Ensure dependencies are installed
|
|
765
|
+
await this.packageInstaller.ensureDependencies();
|
|
766
|
+
// 5. Restart dev server
|
|
767
|
+
await new Promise(r => setTimeout(r, 300));
|
|
768
|
+
await this.devServer.start();
|
|
769
|
+
this.json(res, { success: true, message: 'Dev server restarted with full recovery' });
|
|
749
770
|
}
|
|
750
771
|
catch (err) {
|
|
751
772
|
res.statusCode = 500;
|
package/package.json
CHANGED