docs: remove SSE transport and rename to Streamable HTTP (#6319)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import ExtensionItem from './ExtensionItem';
|
||||
import builtInExtensionsData from '../../../../built-in-extensions.json';
|
||||
import { combineCmdAndArgs } from '../utils';
|
||||
import { quote } from 'shell-quote';
|
||||
import { ExtensionConfig } from '../../../../api';
|
||||
import { FixedExtensionEntry } from '../../../ConfigContext';
|
||||
|
||||
@@ -136,7 +136,7 @@ export function getSubtitle(config: ExtensionConfig) {
|
||||
default:
|
||||
return {
|
||||
description: config.description || null,
|
||||
command: 'cmd' in config ? combineCmdAndArgs(config.cmd, config.args) : null,
|
||||
command: 'cmd' in config ? quote([config.cmd, ...config.args]) : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ import {
|
||||
getDefaultFormData,
|
||||
extensionToFormData,
|
||||
createExtensionConfig,
|
||||
splitCmdAndArgs,
|
||||
combineCmdAndArgs,
|
||||
extractCommand,
|
||||
extractExtensionName,
|
||||
splitCmdAndArgs,
|
||||
DEFAULT_EXTENSION_TIMEOUT,
|
||||
} from './utils';
|
||||
import type { FixedExtensionEntry } from '../../ConfigContext';
|
||||
@@ -245,38 +244,21 @@ describe('Extension Utils', () => {
|
||||
});
|
||||
|
||||
describe('splitCmdAndArgs', () => {
|
||||
it('should split command and arguments correctly', () => {
|
||||
expect(splitCmdAndArgs('python script.py --flag value')).toEqual({
|
||||
cmd: 'python',
|
||||
args: ['script.py', '--flag', 'value'],
|
||||
});
|
||||
|
||||
expect(splitCmdAndArgs('node')).toEqual({
|
||||
cmd: 'node',
|
||||
args: [],
|
||||
});
|
||||
|
||||
expect(splitCmdAndArgs('')).toEqual({
|
||||
cmd: '',
|
||||
args: [],
|
||||
});
|
||||
|
||||
expect(splitCmdAndArgs(' multiple spaces between args ')).toEqual({
|
||||
cmd: 'multiple',
|
||||
args: ['spaces', 'between', 'args'],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('combineCmdAndArgs', () => {
|
||||
it('should combine command and arguments correctly', () => {
|
||||
expect(combineCmdAndArgs('python', ['script.py', '--flag', 'value'])).toBe(
|
||||
'python script.py --flag value'
|
||||
);
|
||||
|
||||
expect(combineCmdAndArgs('node', [])).toBe('node');
|
||||
|
||||
expect(combineCmdAndArgs('', ['arg1', 'arg2'])).toBe(' arg1 arg2');
|
||||
it.each([
|
||||
['python script.py', { cmd: 'python', args: ['script.py'] }],
|
||||
['python script.py --flag', { cmd: 'python', args: ['script.py', '--flag'] }],
|
||||
[
|
||||
"java -classpath '/path/with spaces/lib.jar' Main",
|
||||
{ cmd: 'java', args: ['-classpath', '/path/with spaces/lib.jar', 'Main'] },
|
||||
],
|
||||
[
|
||||
'node --max-old-space-size=4096 app.js',
|
||||
{ cmd: 'node', args: ['--max-old-space-size=4096', 'app.js'] },
|
||||
],
|
||||
[' python script.py ', { cmd: 'python', args: ['script.py'] }],
|
||||
['', { cmd: '', args: [] }],
|
||||
])('splits %j correctly', (input, expected) => {
|
||||
expect(splitCmdAndArgs(input)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { parse, quote } from 'shell-quote';
|
||||
|
||||
// Default extension timeout in seconds
|
||||
// TODO: keep in sync with rust better
|
||||
|
||||
@@ -103,7 +105,7 @@ export function extensionToFormData(extension: FixedExtensionEntry): ExtensionFo
|
||||
extension.type === 'platform'
|
||||
? 'stdio'
|
||||
: extension.type,
|
||||
cmd: extension.type === 'stdio' ? combineCmdAndArgs(extension.cmd, extension.args) : undefined,
|
||||
cmd: extension.type === 'stdio' ? quote([extension.cmd, ...extension.args]) : undefined,
|
||||
endpoint:
|
||||
extension.type === 'streamable_http' || extension.type === 'sse'
|
||||
? (extension.uri ?? undefined)
|
||||
@@ -168,18 +170,8 @@ export function createExtensionConfig(formData: ExtensionFormData): ExtensionCon
|
||||
}
|
||||
|
||||
export function splitCmdAndArgs(str: string): { cmd: string; args: string[] } {
|
||||
const words = str.trim().split(/\s+/);
|
||||
const cmd = words[0] || '';
|
||||
const args = words.slice(1);
|
||||
|
||||
return {
|
||||
cmd,
|
||||
args,
|
||||
};
|
||||
}
|
||||
|
||||
export function combineCmdAndArgs(cmd: string, args: string[]): string {
|
||||
return [cmd, ...args].join(' ');
|
||||
const parts = parse(str.trim()).filter((p): p is string => typeof p === 'string');
|
||||
return { cmd: parts[0] || '', args: parts.slice(1) };
|
||||
}
|
||||
|
||||
export function extractCommand(link: string): string {
|
||||
|
||||
Reference in New Issue
Block a user