Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Implement localhost default address for IntelliJ service config #250

Merged
merged 2 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions nodecg-io-intellij/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core";
import { IntelliJ } from "./intellij";

interface IntelliJServiceConfig {
address: string;
address?: string;
}

export type IntelliJServiceClient = IntelliJ;
Expand All @@ -14,16 +14,15 @@ module.exports = (nodecg: NodeCG) => {

class IntellijService extends ServiceBundle<IntelliJServiceConfig, IntelliJServiceClient> {
async validateConfig(config: IntelliJServiceConfig): Promise<Result<void>> {
const address = config.address;
const ij = new IntelliJ(address);
const ij = new IntelliJ(config.address);
await ij.rawRequest("available_methods", {});
return emptySuccess();
}

async createClient(config: IntelliJServiceConfig): Promise<Result<IntelliJServiceClient>> {
const ij = new IntelliJ(config.address);
await ij.rawRequest("available_methods", {});
this.nodecg.log.info(`Successfully connected to IntelliJ at ${config.address}.`);
this.nodecg.log.info(`Successfully connected to IntelliJ at ${ij.address}.`);
return success(ij);
}

Expand Down
10 changes: 5 additions & 5 deletions nodecg-io-intellij/extension/intellij.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import fetch from "node-fetch";

export class IntelliJ {
private readonly address: string;
readonly address: string;

readonly pluginManager: PluginManager;
readonly localHistory: LocalHistory;

public constructor(address: string) {
this.address = address;
if (address.includes("://")) {
constructor(address?: string) {
// Check if protocol is defined and default to http if missing
if (address?.includes("://")) {
this.address = address;
} else {
this.address = "http://" + address;
this.address = `http://${address ?? "127.0.0.1:19524"}`;
}

this.pluginManager = new PluginManager(this);
Expand Down
2 changes: 1 addition & 1 deletion nodecg-io-intellij/intellij-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"description": "The address where the nodecg-io-intellij server runs. This defaults to 127.0.0.1:19524"
}
},
"required": ["address"]
"required": []
}