Skip to content

Commit

Permalink
support localhost env and custom urls
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiolms committed Oct 10, 2024
1 parent b7ab46c commit c90cd8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import type { WebviewViewProxy } from './webviews/webviewsController';
import { WebviewsController } from './webviews/webviewsController';
import { registerWelcomeWebviewPanel } from './webviews/welcome/registration';

export type Environment = 'dev' | 'staging' | 'production';
export type Environment = 'local' | 'dev' | 'staging' | 'production';

export class Container {
static #instance: Container | undefined;
Expand Down Expand Up @@ -527,6 +527,7 @@ export class Container {
get env(): Environment {
if (this.prereleaseOrDebugging) {
const env = configuration.getAny('gitkraken.env');
if (env === 'local') return 'local';
if (env === 'dev') return 'dev';
if (env === 'staging') return 'staging';
}
Expand Down Expand Up @@ -927,6 +928,11 @@ export class Container {
return Uri.parse('https://dev.gitkraken.dev');
}

if (this.env === 'local') {
const url: string | undefined = configuration.getAny('gitkraken.url.gkdev.base');
return Uri.parse(url ?? 'http://localhost:3000');
}

return Uri.parse('https://gitkraken.dev');
}

Expand Down
11 changes: 11 additions & 0 deletions src/plus/gk/serverConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { memoize } from '../../system/decorators/memoize';
import { Logger } from '../../system/logger';
import type { LogScope } from '../../system/logger.scope';
import { getLogScope } from '../../system/logger.scope';
import { configuration } from '../../system/vscode/configuration';

interface FetchOptions {
cancellation?: CancellationToken;
Expand Down Expand Up @@ -55,6 +56,11 @@ export class ServerConnection implements Disposable {
return Uri.parse('https://devapi.gitkraken.com');
}

if (this.container.env === 'local') {
const url: string | undefined = configuration.getAny('gitkraken.url.api');
return Uri.parse(url ?? 'http://localhost:3000');
}

return Uri.parse('https://api.gitkraken.com');
}

Expand All @@ -72,6 +78,11 @@ export class ServerConnection implements Disposable {
return Uri.parse('https://dev-api.gitkraken.dev');
}

if (this.container.env === 'local') {
const url: string | undefined = configuration.getAny('gitkraken.url.gkdev.api');
return Uri.parse(url ?? 'http://localhost:3000');
}

return Uri.parse('https://api.gitkraken.dev');
}

Expand Down

0 comments on commit c90cd8a

Please sign in to comment.