Skip to content

Commit 3e387ea

Browse files
remove axios
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 6d91d05 commit 3e387ea

14 files changed

Lines changed: 133 additions & 251 deletions

File tree

code/extensions/che-activity-tracker/package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/extensions/che-api/__mocks__/axios.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@
99
***********************************************************************/
1010
/* eslint-disable @typescript-eslint/no-explicit-any */
1111

12-
const axios: any = jest.createMockFromModule('axios');
13-
14-
// map between URL and content
15-
const myContent: Map<string, any> = new Map();
16-
const myErrors: Map<string, any> = new Map();
17-
18-
function __setContent(url: string, content: string): void {
19-
myContent.set(url, content);
20-
}
21-
22-
function __setError(url: string, error: any): void {
23-
myErrors.set(url, error);
24-
}
25-
26-
async function get(url: string): Promise<any> {
27-
if (myErrors.has(url)) {
28-
const storedError = myErrors.get(url);
29-
throw storedError;
30-
}
31-
32-
return { data: myContent.get(url) };
33-
}
34-
function __clearMock(): void {
35-
myContent.clear();
36-
myErrors.clear();
37-
}
38-
39-
axios.get = jest.fn(get);
40-
axios.__setContent = __setContent;
41-
axios.__setError = __setError;
42-
axios.__clearMock = __clearMock;
43-
module.exports = axios;
44-
45-
46-
axios.create = jest.fn();
47-
axios.create.mockResolvedValue(axios);
12+
// const axios: any = jest.createMockFromModule('axios');
13+
14+
// // map between URL and content
15+
// const myContent: Map<string, any> = new Map();
16+
// const myErrors: Map<string, any> = new Map();
17+
18+
// function __setContent(url: string, content: string): void {
19+
// myContent.set(url, content);
20+
// }
21+
22+
// function __setError(url: string, error: any): void {
23+
// myErrors.set(url, error);
24+
// }
25+
26+
// async function get(url: string): Promise<any> {
27+
// if (myErrors.has(url)) {
28+
// const storedError = myErrors.get(url);
29+
// throw storedError;
30+
// }
31+
32+
// return { data: myContent.get(url) };
33+
// }
34+
// function __clearMock(): void {
35+
// myContent.clear();
36+
// myErrors.clear();
37+
// }
38+
39+
// axios.get = jest.fn(get);
40+
// axios.__setContent = __setContent;
41+
// axios.__setError = __setError;
42+
// axios.__clearMock = __clearMock;
43+
// module.exports = axios;
44+
45+
46+
// axios.create = jest.fn();
47+
// axios.create.mockResolvedValue(axios);

code/extensions/che-api/package-lock.json

Lines changed: 0 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/extensions/che-api/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
},
3131
"dependencies": {
3232
"@devfile/api": "^2.3.0-1738854228",
33-
"axios": "^1.7.4",
3433
"@kubernetes/client-node": "^0.22.0",
3534
"fs-extra": "^11.2.0",
3635
"inversify": "^6.0.2",

code/extensions/che-api/src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { GithubService } from './api/github-service';
3030
import { GithubServiceImpl } from './impl/github-service-impl';
3131
import { TelemetryService } from './api/telemetry-service';
3232
import { K8sTelemetryServiceImpl } from './impl/k8s-telemetry-service-impl';
33-
import * as axios from 'axios';
33+
// import * as axios from 'axios';
3434
import { Logger } from './logger';
3535

3636

@@ -43,7 +43,7 @@ export async function activate(_extensionContext: vscode.ExtensionContext): Prom
4343
container.bind(K8SServiceImpl).toSelf().inSingletonScope();
4444
container.bind(K8SService).to(K8SServiceImpl).inSingletonScope();
4545
container.bind(K8sDevWorkspaceEnvVariables).toSelf().inSingletonScope();
46-
container.bind(Symbol.for('AxiosInstance')).toConstantValue(axios);
46+
// container.bind(Symbol.for('AxiosInstance')).toConstantValue(axios);
4747
container.bind(GithubServiceImpl).toSelf().inSingletonScope();
4848
container.bind(GithubService).to(GithubServiceImpl).inSingletonScope();
4949
container.bind(TelemetryService).to(K8sTelemetryServiceImpl).inSingletonScope();

code/extensions/che-api/src/impl/github-service-impl.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/* eslint-disable header/header */
1212

1313
import * as k8s from '@kubernetes/client-node';
14-
import { AxiosInstance } from 'axios';
14+
// import { AxiosInstance } from 'axios';
1515
import * as fs from 'fs-extra';
1616
import { inject, injectable } from 'inversify';
1717
import * as path from 'path';
@@ -39,8 +39,8 @@ export class GithubServiceImpl implements GithubService {
3939

4040
constructor(
4141
@inject(Logger) private logger: Logger,
42-
@inject(K8SServiceImpl) private readonly k8sService: K8SServiceImpl,
43-
@inject(Symbol.for('AxiosInstance')) private readonly axiosInstance: AxiosInstance
42+
@inject(K8SServiceImpl) private readonly k8sService: K8SServiceImpl
43+
// @inject(Symbol.for('AxiosInstance')) private readonly axiosInstance: AxiosInstance
4444
) {
4545
this.initializeToken();
4646
}
@@ -58,18 +58,15 @@ export class GithubServiceImpl implements GithubService {
5858

5959
async getUser(): Promise<GithubUser> {
6060
this.checkToken();
61-
const result = await this.axiosInstance.get<GithubUser>('https://api.github.com/user', {
62-
headers: { Authorization: `Bearer ${this.token}` },
63-
});
64-
return result.data;
61+
// const result = await this.axiosInstance.get<GithubUser>('https://api.github.com/user', {
62+
// headers: { Authorization: `Bearer ${this.token}` },
63+
// });
64+
throw new Error('');
6565
}
6666

6767
async getTokenScopes(token: string): Promise<string[]> {
6868
this.checkToken();
69-
const result = await this.axiosInstance.get<GithubUser>('https://api.github.com/user', {
70-
headers: { Authorization: `Bearer ${token}` },
71-
});
72-
return result.headers['x-oauth-scopes'].split(', ');
69+
throw new Error(`${token}`);
7370
}
7471

7572
async persistDeviceAuthToken(token: string): Promise<void> {

code/extensions/che-api/src/impl/k8s-workspace-service-impl.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import * as k8s from '@kubernetes/client-node';
1414
import { inject, injectable } from 'inversify';
15-
import { AxiosInstance } from "axios";
15+
// import { AxiosInstance } from "axios";
1616
import { K8SServiceImpl } from './k8s-service-impl';
1717
import { K8sDevWorkspaceEnvVariables } from './k8s-devworkspace-env-variables';
1818
import { WorkspaceService } from '../api/workspace-service';
@@ -25,8 +25,8 @@ export class K8sWorkspaceServiceImpl implements WorkspaceService {
2525
@inject(K8sDevWorkspaceEnvVariables)
2626
private env!: K8sDevWorkspaceEnvVariables;
2727

28-
@inject(Symbol.for('AxiosInstance'))
29-
private axiosInstance!: AxiosInstance;
28+
// @inject(Symbol.for('AxiosInstance'))
29+
// private axiosInstance!: AxiosInstance;
3030

3131
public async getNamespace(): Promise<string> {
3232
return this.env.getWorkspaceNamespace();
@@ -53,8 +53,8 @@ export class K8sWorkspaceServiceImpl implements WorkspaceService {
5353
throw new Error('Environment variable MACHINE_EXEC_PORT not found.');
5454
}
5555

56-
const requestUrl = `http://127.0.0.1:${process.env.MACHINE_EXEC_PORT}/activity/tick`;
57-
await this.axiosInstance.post(requestUrl);
56+
// const requestUrl = `http://127.0.0.1:${process.env.MACHINE_EXEC_PORT}/activity/tick`;
57+
// await this.axiosInstance.post(requestUrl);
5858
}
5959

6060
// stopping the workspace is changing the started state to false

code/extensions/che-commands/package-lock.json

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

code/extensions/che-port/package-lock.json

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/extensions/che-remote/package-lock.json

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)