Skip to content

Commit

Permalink
remove local env & replace URLs only if set and pre-release or debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiolms committed Oct 10, 2024
1 parent c90cd8a commit 260cd12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
13 changes: 6 additions & 7 deletions 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 = 'local' | 'dev' | 'staging' | 'production';
export type Environment = 'dev' | 'staging' | 'production';

export class Container {
static #instance: Container | undefined;
Expand Down Expand Up @@ -527,7 +527,6 @@ 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 @@ -920,6 +919,11 @@ export class Container {

@memoize()
private get baseGkDevUri(): Uri {
if (this.prereleaseOrDebugging) {
const url: string | undefined = configuration.getAny('gitkraken.url.gkdev.base');
if (url) return Uri.parse(url);
}

if (this.env === 'staging') {
return Uri.parse('https://staging.gitkraken.dev');
}
Expand All @@ -928,11 +932,6 @@ 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
20 changes: 10 additions & 10 deletions src/plus/gk/serverConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export class ServerConnection implements Disposable {

@memoize()
private get baseApiUri(): Uri {
if (this.container.prereleaseOrDebugging) {
const url: string | undefined = configuration.getAny('gitkraken.url.api');
if (url) return Uri.parse(url);
}

if (this.container.env === 'staging') {
return Uri.parse('https://stagingapi.gitkraken.com');
}
Expand All @@ -56,11 +61,6 @@ 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 @@ -70,6 +70,11 @@ export class ServerConnection implements Disposable {

@memoize()
private get baseGkDevApiUri(): Uri {
if (this.container.prereleaseOrDebugging) {
const url: string | undefined = configuration.getAny('gitkraken.url.gkdev.api');
if (url) return Uri.parse(url);
}

if (this.container.env === 'staging') {
return Uri.parse('https://staging-api.gitkraken.dev');
}
Expand All @@ -78,11 +83,6 @@ 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 260cd12

Please sign in to comment.