feat(cli): Add interactive edit flow to CLI and improve UX
This commit is contained in:
@@ -16,58 +16,12 @@ export function registerEditCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Resolve and load current config
|
||||
// Resolve the target to get the process ID
|
||||
const resolved = await tspmIpcClient.request('resolveTarget', { target: String(target) });
|
||||
const { config } = await tspmIpcClient.request('describe', { id: resolved.id });
|
||||
|
||||
// Interactive editing is temporarily disabled - needs smartinteract API update
|
||||
console.log('Interactive editing is temporarily disabled.');
|
||||
console.log('Current configuration:');
|
||||
console.log(` Name: ${config.name}`);
|
||||
console.log(` Command: ${config.command}`);
|
||||
console.log(` Directory: ${config.projectDir}`);
|
||||
console.log(` Memory: ${formatMemory(config.memoryLimitBytes)}`);
|
||||
console.log(` Auto-restart: ${config.autorestart}`);
|
||||
console.log(` Watch: ${config.watch ? 'enabled' : 'disabled'}`);
|
||||
|
||||
// For now, just update environment variables to current
|
||||
const essentialEnvVars: NodeJS.ProcessEnv = {
|
||||
PATH: process.env.PATH || '',
|
||||
HOME: process.env.HOME,
|
||||
USER: process.env.USER,
|
||||
SHELL: process.env.SHELL,
|
||||
LANG: process.env.LANG,
|
||||
LC_ALL: process.env.LC_ALL,
|
||||
// Node.js specific
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
NODE_PATH: process.env.NODE_PATH,
|
||||
// npm/pnpm/yarn paths
|
||||
npm_config_prefix: process.env.npm_config_prefix,
|
||||
// Include any TSPM_ prefixed vars
|
||||
...Object.fromEntries(
|
||||
Object.entries(process.env).filter(([key]) => key.startsWith('TSPM_'))
|
||||
),
|
||||
};
|
||||
|
||||
// Remove undefined values
|
||||
Object.keys(essentialEnvVars).forEach(key => {
|
||||
if (essentialEnvVars[key] === undefined) {
|
||||
delete essentialEnvVars[key];
|
||||
}
|
||||
});
|
||||
|
||||
// Update environment variables
|
||||
const updates = {
|
||||
env: { ...(config.env || {}), ...essentialEnvVars }
|
||||
};
|
||||
|
||||
const updateResponse = await tspmIpcClient.request('update', {
|
||||
id: resolved.id,
|
||||
updates,
|
||||
});
|
||||
|
||||
console.log('✓ Environment variables updated');
|
||||
console.log(' Process configuration updated successfully');
|
||||
// Use the shared interactive edit function
|
||||
const { interactiveEditProcess } = await import('../../helpers/interactive-edit.js');
|
||||
await interactiveEditProcess(resolved.id);
|
||||
},
|
||||
{ actionLabel: 'edit process config' },
|
||||
);
|
||||
|
Reference in New Issue
Block a user