Skip to content

Commit

Permalink
fix(eclipse): include tabby-agent in package. (#2732)
Browse files Browse the repository at this point in the history
* fix(eclipse): include tabby-agent in package.

* chore(eclipse): format code.
  • Loading branch information
icycodes authored Jul 26, 2024
1 parent 23fbaad commit f02677f
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 46 deletions.
2 changes: 2 additions & 0 deletions clients/eclipse/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist
node_modules
plugin/tabby-agent
4 changes: 2 additions & 2 deletions clients/eclipse/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="com.tabbyml.features.tabby4eclipse"
label="Tabby"
version="0.0.1.1"
version="0.0.1.2"
provider-name="com.tabbyml">

<description url="http://www.example.com/description">
Expand All @@ -19,6 +19,6 @@

<plugin
id="com.tabbyml.tabby4eclipse"
version="0.0.0"/>
version="0.0.1.2"/>

</feature>
11 changes: 11 additions & 0 deletions clients/eclipse/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "tabby4eclipse",
"private": true,
"scripts": {
"postinstall": "node scripts/copy-tabby-agent.js"
},
"devDependencies": {
"tabby-agent": "workspace:*",
"fs-extra": "^11.1.1"
}
}
2 changes: 1 addition & 1 deletion clients/eclipse/plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tabby Plugin for Eclipse
Bundle-SymbolicName: com.tabbyml.tabby4eclipse;singleton:=true
Bundle-Version: 0.0.1.1
Bundle-Version: 0.0.1.2
Bundle-Activator: com.tabbyml.tabby4eclipse.Activator
Bundle-Vendor: com.tabbyml
Require-Bundle: org.eclipse.ui,
Expand Down
1 change: 1 addition & 0 deletions clients/eclipse/plugin/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
tabby-agent/,\
.\
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,34 @@

public class ConnectionProvider extends ProcessStreamConnectionProvider {
private Logger logger = new Logger("ConnectionProvider");

public ConnectionProvider() {
List<String> commands = List.of("npx", "[email protected]", "--stdio");
logger.info("Will use command " + commands.toString() + " to start Tabby language server.");
this.setCommands(commands);
try {
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
URL agentScriptUrl = FileLocator.find(bundle, new Path("tabby-agent/dist/node/index.js"));
if (agentScriptUrl == null) {
logger.error("Cannot find tabby-agent script.");
return;
}
File agentScriptFile = new File(FileLocator.toFileURL(agentScriptUrl).getPath());
List<String> commands = List.of("node", agentScriptFile.getAbsolutePath(), "--stdio");
logger.info("Will use command " + commands.toString() + " to start Tabby language server.");
this.setCommands(commands);
} catch (IOException e) {
logger.error("Failed to setup command to start Tabby language server.", e);
}
}

@Override
public void start() throws IOException {
super.start();
logger.info("Tabby language server started.");
}

@Override
public void stop() {
super.stop();
logger.info("Tabby language server stopped.");
}

}
22 changes: 22 additions & 0 deletions clients/eclipse/scripts/copy-tabby-agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

const fs = require('fs-extra');
const path = require('path');

const cwd = process.cwd();
const sourceDir = path.join(cwd, 'node_modules', 'tabby-agent', 'dist', 'node');
const targetDir = path.join(cwd, 'plugin', 'tabby-agent', 'dist', 'node');

async function copyFiles() {
try {
await fs.emptyDir(targetDir);
await fs.copy(sourceDir, targetDir, {
filter: (src) => !src.endsWith('.js.map')
});
console.log('✅ Files copied: node_modules/tabby-agent/dist/node -> plugin/tabby-agent/dist/node');
} catch (err) {
console.error('❌ Error copying files:', err);
}
}

copyFiles();
Loading

0 comments on commit f02677f

Please sign in to comment.