feat(cli): Correct CLI plugin imports and add reset command/IPC to stop processes and clear persisted configs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import * as paths from '../../../paths.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import { Logger } from '../../../shared/common/utils.errorhandler.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as paths from '../../paths.js';
|
||||
import { tspmIpcClient } from '../../client/tspm.ipcclient.js';
|
||||
import { Logger } from '../../shared/common/utils.errorhandler.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { parseMemoryString, formatMemory } from '../../helpers/memory.js';
|
||||
@@ -88,4 +88,3 @@ export function registerAddCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
{ actionLabel: 'add process config' },
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { IProcessConfig } from '../../../shared/protocol/ipc.types.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { tspmIpcClient } from '../../../client/tspm.ipcclient.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
import { registerIpcCommand } from '../../registration/index.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { registerIpcCommand } from '../registration/index.js';
|
||||
import { tspmIpcClient } from '../../client/tspm.ipcclient.js';
|
||||
|
||||
@@ -18,33 +18,16 @@ export function registerResetCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop all processes first
|
||||
const stopAllRes = await tspmIpcClient.request('stopAll', {});
|
||||
if (stopAllRes.failed.length) {
|
||||
console.log(
|
||||
`Stopped ${stopAllRes.stopped.length}, ${stopAllRes.failed.length} failed to stop. Proceeding with config reset...`,
|
||||
);
|
||||
} else {
|
||||
console.log(`Stopped ${stopAllRes.stopped.length} processes.`);
|
||||
// Single IPC call to reset
|
||||
const result = await tspmIpcClient.request('reset', {});
|
||||
const failedCount = result.failed.length;
|
||||
console.log(`Stopped ${result.stopped.length} processes.`);
|
||||
if (failedCount) {
|
||||
console.log(`${failedCount} processes failed to stop (configs cleared anyway).`);
|
||||
}
|
||||
|
||||
// List all processes/configs currently known
|
||||
const listRes = await tspmIpcClient.request('list', {});
|
||||
|
||||
// Remove each config
|
||||
for (const proc of listRes.processes) {
|
||||
try {
|
||||
// Prefer 'remove' which handles stop-if-running semantics as well
|
||||
await tspmIpcClient.request('remove', { id: proc.id });
|
||||
console.log(`Removed config for process ${proc.id}.`);
|
||||
} catch (err) {
|
||||
console.error(`Failed to remove config for ${proc.id}:`, (err as Error)?.message || String(err));
|
||||
}
|
||||
}
|
||||
|
||||
console.log('TSPM has been reset: processes stopped and configs cleared.');
|
||||
console.log(`Cleared ${result.removed.length} saved configurations.`);
|
||||
console.log('TSPM has been reset.');
|
||||
},
|
||||
{ actionLabel: 'reset TSPM' },
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { TspmServiceManager } from '../../../client/tspm.servicemanager.js';
|
||||
import { Logger } from '../../../shared/common/utils.errorhandler.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { TspmServiceManager } from '../../../client/tspm.servicemanager.js';
|
||||
import { Logger } from '../../../shared/common/utils.errorhandler.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
|
Reference in New Issue
Block a user