feat(cli): Add interactive edit command and update support for process configurations
This commit is contained in:
@@ -197,6 +197,32 @@ export class ProcessManager extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing process configuration
|
||||
*/
|
||||
public async update(
|
||||
id: ProcessId,
|
||||
updates: Partial<Omit<IProcessConfig, 'id'>>,
|
||||
): Promise<IProcessConfig> {
|
||||
const existing = this.processConfigs.get(id);
|
||||
if (!existing) {
|
||||
throw new ValidationError(
|
||||
`Process with id '${id}' does not exist`,
|
||||
'ERR_PROCESS_NOT_FOUND',
|
||||
);
|
||||
}
|
||||
|
||||
// Shallow merge; keep id intact
|
||||
const merged: IProcessConfig = {
|
||||
...existing,
|
||||
...updates,
|
||||
} as IProcessConfig;
|
||||
|
||||
this.processConfigs.set(id, merged);
|
||||
await this.saveProcessConfigs();
|
||||
return merged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a process by id
|
||||
*/
|
||||
|
@@ -47,7 +47,7 @@ export class ProcessWrapper extends EventEmitter {
|
||||
this.options.args,
|
||||
{
|
||||
cwd: this.options.cwd,
|
||||
env: this.options.env || process.env,
|
||||
env: { ...process.env, ...(this.options.env || {}) },
|
||||
stdio: ['ignore', 'pipe', 'pipe'], // We need to pipe stdout and stderr
|
||||
},
|
||||
);
|
||||
@@ -55,7 +55,7 @@ export class ProcessWrapper extends EventEmitter {
|
||||
// Use shell mode to allow a full command string
|
||||
this.process = plugins.childProcess.spawn(this.options.command, {
|
||||
cwd: this.options.cwd,
|
||||
env: this.options.env || process.env,
|
||||
env: { ...process.env, ...(this.options.env || {}) },
|
||||
stdio: ['ignore', 'pipe', 'pipe'], // We need to pipe stdout and stderr
|
||||
shell: true,
|
||||
});
|
||||
|
@@ -233,6 +233,19 @@ export class TspmDaemon {
|
||||
},
|
||||
);
|
||||
|
||||
this.ipcServer.onMessage(
|
||||
'update',
|
||||
async (request: RequestForMethod<'update'>) => {
|
||||
try {
|
||||
const id = toProcessId(request.id);
|
||||
const updated = await this.tspmInstance.update(id, request.updates as any);
|
||||
return { id, config: updated };
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to update process: ${error.message}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
this.ipcServer.onMessage(
|
||||
'remove',
|
||||
async (request: RequestForMethod<'remove'>) => {
|
||||
|
Reference in New Issue
Block a user