nstantpage-agent 0.5.15 → 0.5.16
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 +18 -3
- package/dist/tunnel.d.ts +3 -1
- package/dist/tunnel.js +4 -4
- 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.16';
|
|
29
29
|
/**
|
|
30
30
|
* Resolve the backend API base URL.
|
|
31
31
|
* - If --backend is passed, use it
|
|
@@ -499,8 +499,23 @@ async function startStandbyMode(token, options, backendUrl, deviceId) {
|
|
|
499
499
|
projectId: '_standby_',
|
|
500
500
|
apiPort: 0,
|
|
501
501
|
devPort: 0,
|
|
502
|
-
onStartProject: async (pid) => {
|
|
503
|
-
|
|
502
|
+
onStartProject: async (pid, opts) => {
|
|
503
|
+
const isClean = opts?.clean === true;
|
|
504
|
+
// If clean reset requested and project is already running, stop it first
|
|
505
|
+
if (isClean && activeProjects.has(pid)) {
|
|
506
|
+
console.log(chalk.yellow(` Stopping existing project ${pid} for clean reset...`));
|
|
507
|
+
const existing = activeProjects.get(pid);
|
|
508
|
+
existing.tunnel.disconnect();
|
|
509
|
+
await existing.localServer.stop();
|
|
510
|
+
activeProjects.delete(pid);
|
|
511
|
+
// Wipe the project directory
|
|
512
|
+
const projectDir = resolveProjectDir('.', pid);
|
|
513
|
+
if (fs.existsSync(projectDir)) {
|
|
514
|
+
console.log(chalk.gray(` Wiping project directory: ${projectDir}`));
|
|
515
|
+
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
else if (activeProjects.has(pid)) {
|
|
504
519
|
console.log(chalk.yellow(` Project ${pid} is already running`));
|
|
505
520
|
return;
|
|
506
521
|
}
|
package/dist/tunnel.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ interface TunnelClientOptions {
|
|
|
24
24
|
/** Port where the dev server (Vite/Next.js) runs */
|
|
25
25
|
devPort: number;
|
|
26
26
|
/** Callback when gateway requests starting a new project on this device */
|
|
27
|
-
onStartProject?: (projectId: string
|
|
27
|
+
onStartProject?: (projectId: string, options?: {
|
|
28
|
+
clean?: boolean;
|
|
29
|
+
}) => Promise<void>;
|
|
28
30
|
/** Callback for setup progress — lets the standby tunnel relay phases to gateway */
|
|
29
31
|
onSetupProgress?: (projectId: string, phase: string, message: string) => void;
|
|
30
32
|
}
|
package/dist/tunnel.js
CHANGED
|
@@ -246,8 +246,8 @@ export class TunnelClient {
|
|
|
246
246
|
* Handle start-project: gateway wants this agent to start serving a new project.
|
|
247
247
|
* Called when user clicks "Connect" in the web editor's Cloud panel.
|
|
248
248
|
*/
|
|
249
|
-
async handleStartProject(projectId) {
|
|
250
|
-
console.log(` [Tunnel] Received start-project command for ${projectId}`);
|
|
249
|
+
async handleStartProject(projectId, clean) {
|
|
250
|
+
console.log(` [Tunnel] Received start-project command for ${projectId}${clean ? ' (clean)' : ''}`);
|
|
251
251
|
if (!projectId) {
|
|
252
252
|
this.send({ type: 'start-project-result', success: false, error: 'Missing projectId' });
|
|
253
253
|
return;
|
|
@@ -256,7 +256,7 @@ export class TunnelClient {
|
|
|
256
256
|
try {
|
|
257
257
|
// Send initial progress
|
|
258
258
|
this.sendSetupProgress(projectId, 'starting', 'Starting project setup...');
|
|
259
|
-
await this.options.onStartProject(projectId);
|
|
259
|
+
await this.options.onStartProject(projectId, clean ? { clean: true } : undefined);
|
|
260
260
|
this.sendSetupProgress(projectId, 'ready', 'Project is live!');
|
|
261
261
|
this.send({ type: 'start-project-result', projectId, success: true });
|
|
262
262
|
}
|
|
@@ -300,7 +300,7 @@ export class TunnelClient {
|
|
|
300
300
|
this.handleWsClose(msg.wsId);
|
|
301
301
|
break;
|
|
302
302
|
case 'start-project':
|
|
303
|
-
this.handleStartProject(msg.projectId);
|
|
303
|
+
this.handleStartProject(msg.projectId, msg.clean);
|
|
304
304
|
break;
|
|
305
305
|
default:
|
|
306
306
|
console.warn(` [Tunnel] Unknown message type: ${msg.type}`);
|
package/package.json
CHANGED