Initialize remote IDE scaffold
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import {
|
||||
createRemoteBootstrapCommand,
|
||||
createRemoteInstallCommand,
|
||||
createRemoteServerInstallPlan,
|
||||
joinRemotePath,
|
||||
quoteShellArg,
|
||||
} from '../packages/server-installer/ts/index.js';
|
||||
|
||||
tap.test('should create stable remote install paths', async () => {
|
||||
const plan = createRemoteServerInstallPlan({
|
||||
serverVersion: '0.1.0',
|
||||
artifactName: 'remote-theia-linux-x64.tgz',
|
||||
installRoot: '~/.git.zone/ide-server',
|
||||
platform: 'linux',
|
||||
arch: 'x64',
|
||||
});
|
||||
|
||||
expect(plan.paths.versionRoot).toEqual('~/.git.zone/ide-server/0.1.0');
|
||||
expect(plan.paths.currentLink).toEqual('~/.git.zone/ide-server/current');
|
||||
expect(plan.manifest.protocolVersion).toEqual(1);
|
||||
expect(plan.manifest.artifactName).toEqual('remote-theia-linux-x64.tgz');
|
||||
});
|
||||
|
||||
tap.test('should quote shell arguments safely', async () => {
|
||||
expect(quoteShellArg("that's it")).toEqual("'that'\"'\"'s it'");
|
||||
expect(joinRemotePath('~/.git.zone/', '/ide-server/', '/0.1.0')).toEqual('~/.git.zone/ide-server/0.1.0');
|
||||
});
|
||||
|
||||
tap.test('should render install and bootstrap commands', async () => {
|
||||
const plan = createRemoteServerInstallPlan({
|
||||
serverVersion: '0.1.0',
|
||||
artifactName: 'remote-theia.tgz',
|
||||
});
|
||||
const installCommand = createRemoteInstallCommand(plan);
|
||||
const bootstrapCommand = createRemoteBootstrapCommand({
|
||||
serverVersion: '0.1.0',
|
||||
workspacePath: '/srv/work/project',
|
||||
theiaPort: 33990,
|
||||
opencodePort: 4096,
|
||||
opencodeUsername: 'opencode',
|
||||
opencodePassword: 'secret',
|
||||
});
|
||||
|
||||
expect(installCommand).toInclude('GITZONE_IDE_MANIFEST');
|
||||
expect(bootstrapCommand).toInclude('GITZONE_IDE_OPENCODE_PORT');
|
||||
expect(bootstrapCommand).toInclude('pnpm --dir');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
@@ -0,0 +1,17 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import { parseServerSentEvent } from '../packages/opencode-bridge/ts/index.js';
|
||||
|
||||
tap.test('should parse named opencode sse events', async () => {
|
||||
const event = parseServerSentEvent('id: 1\nevent: server.connected\ndata: {"type":"server.connected"}\n');
|
||||
expect(event!.id).toEqual('1');
|
||||
expect(event!.type).toEqual('server.connected');
|
||||
expect(event!.data).toEqual({ type: 'server.connected' });
|
||||
});
|
||||
|
||||
tap.test('should infer opencode event type from json data', async () => {
|
||||
const event = parseServerSentEvent('data: {"type":"session.updated","properties":{"id":"abc"}}\n');
|
||||
expect(event!.type).toEqual('session.updated');
|
||||
expect(event!.data).toEqual({ type: 'session.updated', properties: { id: 'abc' } });
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
@@ -0,0 +1,47 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import { buildSshArgs, listConnectableHosts, parseSshConfig } from '../packages/ssh/ts/index.js';
|
||||
|
||||
tap.test('should parse ssh config hosts', async () => {
|
||||
const hosts = parseSshConfig(`
|
||||
Host *
|
||||
ServerAliveInterval 30
|
||||
|
||||
Host dev-box staging-box
|
||||
HostName dev.example.com
|
||||
User deploy
|
||||
Port 2222
|
||||
IdentityFile ~/.ssh/id_ed25519
|
||||
ProxyJump bastion
|
||||
|
||||
Host *.internal
|
||||
User ignored
|
||||
`);
|
||||
|
||||
const connectableHosts = listConnectableHosts(hosts);
|
||||
expect(connectableHosts).toHaveLength(2);
|
||||
expect(connectableHosts[0]!.alias).toEqual('dev-box');
|
||||
expect(connectableHosts[0]!.hostName).toEqual('dev.example.com');
|
||||
expect(connectableHosts[0]!.user).toEqual('deploy');
|
||||
expect(connectableHosts[0]!.port).toEqual(2222);
|
||||
expect(connectableHosts[0]!.identityFiles[0]!).toEndWith('/.ssh/id_ed25519');
|
||||
expect(connectableHosts[0]!.proxyJump).toEqual('bastion');
|
||||
});
|
||||
|
||||
tap.test('should build ssh args with destination and command', async () => {
|
||||
const args = buildSshArgs(
|
||||
{
|
||||
id: 'dev-box',
|
||||
hostAlias: 'dev-box',
|
||||
user: 'deploy',
|
||||
port: 2222,
|
||||
},
|
||||
'uname -a',
|
||||
);
|
||||
|
||||
expect(args).toContain('-p');
|
||||
expect(args).toContain('2222');
|
||||
expect(args).toContain('deploy@dev-box');
|
||||
expect(args[args.length - 1]).toEqual('uname -a');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user