Skip to content

Commit 69dbf69

Browse files
committed
Cleanup Changes
1 parent cc803fc commit 69dbf69

30 files changed

+755
-609
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "https://www.raycast.com/schemas/extension.json",
33
"name": "gitpod",
4-
"title": "Gitpod (Beta)",
4+
"title": "Gitpod",
55
"description": "A blazingly fast way to work with Gitpod",
66
"icon": "logo-mark.png",
77
"author": "Henit-Palani",
8-
"owner": "gitpod-community",
8+
"access": "public",
99
"contributors": [
1010
"Palanikannan1437",
1111
"henitchobisa"
@@ -82,7 +82,7 @@
8282
"commands": [
8383
{
8484
"name": "open_in_gitpod",
85-
"title": "Open Contexts from Github",
85+
"title": "Open Contexts From Github",
8686
"subtitle": "Open any Context in Gitpod",
8787
"description": "Open any Repository / Branch / PR / Issue in Gitpod with the extension",
8888
"mode": "view",
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export interface IOrganizationError extends Error {
2-
code: number,
3-
message: string,
2+
code: number;
3+
message: string;
44
}
55

6-
export function NewIOrganizationErrorObject(jsonObj: any): IOrganizationError{
7-
const error :IOrganizationError = {
8-
name : "OrganizationError",
9-
code : jsonObj.code ?? 0,
10-
message: jsonObj.message ?? ""
11-
}
12-
return error;
13-
}
6+
export function NewIOrganizationErrorObject(jsonObj: any): IOrganizationError {
7+
const error: IOrganizationError = {
8+
name: "OrganizationError",
9+
code: jsonObj.code ?? 0,
10+
message: jsonObj.message ?? "",
11+
};
12+
return error;
13+
}

src/api/Gitpod/Models/IOrganizations.ts

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,60 @@ import { IOrganizationError } from "./IOrganizationError";
44
import { GitpodDataModel } from "./Model";
55

66
const organizationURLs = {
7-
getOrganizations: "https://api.gitpod.io/gitpod.experimental.v1.TeamsService/ListTeams"
8-
}
7+
getOrganizations: "https://api.gitpod.io/gitpod.experimental.v1.TeamsService/ListTeams",
8+
};
99

1010
export class IOrganization implements GitpodDataModel {
11-
private token: string;
12-
public orgId: string;
13-
public name: string;
14-
public slug: string;
15-
16-
constructor(organization: any ,token: string) {
17-
this.orgId = organization.id;
18-
this.name = organization.name;
19-
this.slug = organization.slug;
20-
21-
this.token = token;
11+
private token: string;
12+
public orgId: string;
13+
public name: string;
14+
public slug: string;
15+
16+
constructor(organization: any, token: string) {
17+
this.orgId = organization.id;
18+
this.name = organization.name;
19+
this.slug = organization.slug;
20+
21+
this.token = token;
22+
}
23+
24+
parse(json: string): IOrganization {
25+
const data = JSON.parse(json);
26+
27+
this.orgId = data.id ?? "";
28+
this.name = data.name ?? "";
29+
this.slug = data.slug ?? "";
30+
31+
return this;
32+
}
33+
34+
static fetchOrganization = async (token: string): Promise<IOrganization[]> => {
35+
const organizations: IOrganization[] = [];
36+
const response = await fetch(organizationURLs.getOrganizations, {
37+
method: "POST",
38+
headers: {
39+
"content-type": "application/json",
40+
Authorization: `Bearer ${token}`,
41+
},
42+
body: JSON.stringify({}),
43+
});
44+
45+
if (response.status !== 200) {
46+
const error: IOrganizationError = {
47+
name: "OrganizationFetchError",
48+
code: response.status,
49+
message: response.statusText,
50+
};
51+
throw error;
2252
}
2353

24-
parse(json: string): IOrganization {
25-
const data = JSON.parse(json);
54+
const json = (await response.json()) as any;
2655

27-
this.orgId = data.id ?? "";
28-
this.name = data.name ?? "";
29-
this.slug = data.slug ?? "";
56+
json.teams.map((organization: unknown) => {
57+
const org = new IOrganization(organization, token);
58+
organizations.push(org);
59+
});
3060

31-
return this
32-
}
33-
34-
static fetchOrganization = async (token: string): Promise<IOrganization[]> => {
35-
const organizations: IOrganization[] = []
36-
const response = await fetch(organizationURLs.getOrganizations, {
37-
method: "POST",
38-
headers: {
39-
"content-type": "application/json",
40-
"Authorization": `Bearer ${token}`,
41-
},
42-
body: JSON.stringify({}),
43-
})
44-
45-
if (response.status !== 200){
46-
const error : IOrganizationError = {
47-
name: "OrganizationFetchError",
48-
code: response.status,
49-
message: response.statusText
50-
}
51-
throw error;
52-
}
53-
54-
const json = await response.json() as any;
55-
56-
json.teams.map((organization: unknown) => {
57-
const org = new IOrganization(organization, token);
58-
organizations.push(org)
59-
})
60-
61-
return organizations
62-
}
63-
}
61+
return organizations;
62+
};
63+
}

src/api/Gitpod/Models/IWorkspace.ts

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import fetch from 'node-fetch';
1+
import fetch from "node-fetch";
22

3-
import { CreateWorkspace, WorkspaceStreamer } from '../WorkspaceStreamer';
3+
import { CreateWorkspace, WorkspaceStreamer } from "../WorkspaceStreamer";
44

5-
import { IWorkspaceError } from './IWorkspaceError';
5+
import { IWorkspaceError } from "./IWorkspaceError";
66
import { GitpodDataModel } from "./Model";
77

88
type IWorkspaceParams = {
@@ -17,15 +17,15 @@ type ICreateWorkspaceParams = {
1717
ideSetting: {
1818
defaultIde: string;
1919
useLatestVersion: false;
20-
}
21-
}
20+
};
21+
};
2222

2323
const workspaceURLs = {
2424
getWorkspace: "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/GetWorkspace",
2525
getAllWorkspaces: "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/ListWorkspaces",
2626
deleteWorkspace: "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/DeleteWorkspace",
2727
startWorkspace: "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/StartWorkspace",
28-
stopWorkspace: "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/StopWorkspace"
28+
stopWorkspace: "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/StopWorkspace",
2929
};
3030

3131
export class IWorkspace implements GitpodDataModel {
@@ -43,15 +43,15 @@ export class IWorkspace implements GitpodDataModel {
4343
};
4444
private description: string;
4545
public instanceId: string;
46-
public createdAt: string
46+
public createdAt: string;
4747
private status: {
4848
phase: string;
4949
};
5050

5151
private repository: string;
5252

5353
getIDEURL() {
54-
return this.ideURL
54+
return this.ideURL;
5555
}
5656

5757
setIDEURL(url: string) {
@@ -98,8 +98,8 @@ export class IWorkspace implements GitpodDataModel {
9898
return this.description;
9999
}
100100

101-
getRepositoryName(): string{
102-
if (!this.initialized){
101+
getRepositoryName(): string {
102+
if (!this.initialized) {
103103
throw new Error("IWorkspace instance not initailized");
104104
}
105105
return this.repository;
@@ -120,11 +120,11 @@ export class IWorkspace implements GitpodDataModel {
120120
this.status = workspace.status.instance.status;
121121
this.description = workspace.description;
122122
this.token = token;
123-
this.instanceId = workspace.status.instance.instanceId
123+
this.instanceId = workspace.status.instance.instanceId;
124124
this.initialized = true;
125-
this.createdAt = workspace.status.instance.createdAt
126-
this.ideURL = workspace.status.instance ? workspace.status.instance.status.url : 'https://gitpod.io';
127-
this.repository = workspace.context.git.repository.name
125+
this.createdAt = workspace.status.instance.createdAt;
126+
this.ideURL = workspace.status.instance ? workspace.status.instance.status.url : "https://gitpod.io";
127+
this.repository = workspace.context.git.repository.name;
128128
}
129129

130130
parse(json: string): IWorkspace {
@@ -144,9 +144,9 @@ export class IWorkspace implements GitpodDataModel {
144144
this.status = {
145145
phase: data.result.status.instance.status.phase,
146146
};
147-
this.ideURL = data.result.status.instance ? data.result.status.instance.status.url : ''
147+
this.ideURL = data.result.status.instance ? data.result.status.instance.status.url : "";
148148

149-
this.createdAt = data.result.status.instance.createdAt
149+
this.createdAt = data.result.status.instance.createdAt;
150150

151151
return this;
152152
}
@@ -167,23 +167,26 @@ export class IWorkspace implements GitpodDataModel {
167167
method: "POST",
168168
headers: {
169169
"content-type": "application/json",
170-
"Authorization": `Bearer ${this.token}`,
170+
Authorization: `Bearer ${this.token}`,
171171
},
172172
body: JSON.stringify({ workspaceId: workspaceID }),
173173
});
174174
const json = await response.json();
175175
if (response.status !== 200) {
176-
const errorState = json as { code?: string, message?: string }
176+
const errorState = json as { code?: string; message?: string };
177177
const error: IWorkspaceError = {
178178
name: "WorkspaceStartError",
179179
code: response.status,
180-
message: errorState.message && errorState.message.startsWith("You cannot run more than 4 workspaces at the same time") ? errorState.message : "Error Occured in Starting Workspace"
181-
}
182-
throw error
180+
message:
181+
errorState.message && errorState.message.startsWith("You cannot run more than 4 workspaces at the same time")
182+
? errorState.message
183+
: "Error Occured in Starting Workspace",
184+
};
185+
throw error;
183186
}
184187
const workspace = this.parse(JSON.stringify(json));
185188
return workspace;
186-
}
189+
};
187190

188191
public stop: (params: IWorkspaceParams) => void = async (params: IWorkspaceParams) => {
189192
const { workspaceID } = params;
@@ -192,7 +195,7 @@ export class IWorkspace implements GitpodDataModel {
192195
method: "POST",
193196
headers: {
194197
"content-type": "application/json",
195-
"Authorization": `Bearer ${this.token}`,
198+
Authorization: `Bearer ${this.token}`,
196199
},
197200
body: JSON.stringify({ workspaceId: workspaceID }),
198201
});
@@ -201,32 +204,32 @@ export class IWorkspace implements GitpodDataModel {
201204
const error: IWorkspaceError = {
202205
name: "WorkspaceStartError",
203206
code: response.status,
204-
message: "Error Occured in Stopping Workspace"
205-
}
206-
throw error
207+
message: "Error Occured in Stopping Workspace",
208+
};
209+
throw error;
207210
}
208-
}
209-
210-
public static create: (streamer: WorkspaceStreamer, params: ICreateWorkspaceParams) => void = async (streamer: WorkspaceStreamer, params: ICreateWorkspaceParams) => {
211+
};
211212

213+
public static create: (streamer: WorkspaceStreamer, params: ICreateWorkspaceParams) => void = async (
214+
streamer: WorkspaceStreamer,
215+
params: ICreateWorkspaceParams
216+
) => {
212217
const createParams: CreateWorkspace = {
213218
method: "createWorkspace",
214-
params: params
215-
}
219+
params: params,
220+
};
216221

217-
streamer.execute(createParams)
218-
}
222+
streamer.execute(createParams);
223+
};
219224

220-
public fetch: (params: IWorkspaceParams) => Promise<IWorkspace> | never = async (
221-
params: IWorkspaceParams
222-
) => {
225+
public fetch: (params: IWorkspaceParams) => Promise<IWorkspace> | never = async (params: IWorkspaceParams) => {
223226
const { workspaceID } = params;
224227

225228
const response = await fetch(workspaceURLs.getWorkspace, {
226229
method: "GET",
227230
headers: {
228231
"content-type": "application/json",
229-
"Authorization": `Bearer ${this.token}`,
232+
Authorization: `Bearer ${this.token}`,
230233
},
231234
body: JSON.stringify({ workspaceID }),
232235
});
@@ -235,9 +238,9 @@ export class IWorkspace implements GitpodDataModel {
235238
const error: IWorkspaceError = {
236239
name: "WorkspaceFetchError",
237240
code: response.status,
238-
message: response.statusText
239-
}
240-
throw error
241+
message: response.statusText,
242+
};
243+
throw error;
241244
}
242245

243246
const json = await response.json();
@@ -252,27 +255,27 @@ export class IWorkspace implements GitpodDataModel {
252255
method: "POST",
253256
headers: {
254257
"content-type": "application/json",
255-
"Authorization": `Bearer ${token}`,
258+
Authorization: `Bearer ${token}`,
256259
},
257260
body: JSON.stringify({}),
258-
})
261+
});
259262
if (response.status != 200) {
260263
const error: IWorkspaceError = {
261264
name: "WorkspaceFetchError",
262265
code: response.status,
263-
message: response.statusText
264-
}
265-
throw error
266+
message: response.statusText,
267+
};
268+
throw error;
266269
}
267270

268-
const json = await response.json() as any;
271+
const json = (await response.json()) as any;
269272

270273
json.result.map((workspace: unknown) => {
271274
const space = new IWorkspace(workspace, token);
272275
workspaceMap.set(space.workspaceId, space);
273-
})
274-
return workspaceMap
275-
}
276+
});
277+
return workspaceMap;
278+
};
276279

277280
// public delete = async () => {
278281
// const response = await fetch(workspaceURLs.deleteWorkspace, {

0 commit comments

Comments
 (0)