Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove code to get a minimal Hypercrx so we can refactor it without too much burden #547

Merged
merged 10 commits into from
Dec 5, 2022
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
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
"@fluentui/react": "^8.62.0",
"@fluentui/react-hooks": "^8.3.13",
"@hot-loader/react-dom": "^17.0.2",
"@octokit/core": "^3.5.1",
"@uifabric/icons": "^7.6.2",
"buffer": "^6.0.3",
"delegated-events": "^1.1.2",
"echarts": "^5.3.0",
"github-url-detection": "^5.8.0",
"jquery": "^3.6.0",
Expand Down
5 changes: 0 additions & 5 deletions scripts/bump-version.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ async function bump({ version, deploy }) {
}
update_info.develop.latest_version = version;
writeJson(infoPath, update_info);

// update background.data.ts
processFile('src/mock/background.data.ts', (content) =>
content.replace(/(latest_version)\:.*?,/g, `$1: '${version}',`)
);
}

module.exports = { bump };
18 changes: 3 additions & 15 deletions src/Perceptor.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { utils, isRepo } from 'github-url-detection';
import { loadSettings, mergeSettings } from './utils/settings';
import { getConfigFromGithub } from './api/github';
import { loadSettings } from './utils/settings';
import PerceptorBase from './PerceptorBase';
import logger from './utils/logger';

export class Perceptor extends PerceptorBase {
public static Features: Map<string, any> = new Map();
public settings: any;
public hypertronsConfig: any;

public async run(): Promise<void> {
logger.info('start.');
Expand All @@ -19,19 +17,9 @@ export class Perceptor extends PerceptorBase {
private async checkSettings(): Promise<void> {
logger.info('loading settings ...');
if (isRepo()) {
logger.info(
'Detected that this is a repo page, trying to load configuration file from the repo ...'
);
const owner = utils.getRepositoryInfo(window.location)!.owner;
const repo = utils.getRepositoryInfo(window.location)!.name;
const configHypertrons = await getConfigFromGithub(owner, repo);
logger.info('The configurations are: ', configHypertrons);
this.hypertronsConfig = configHypertrons;
if ('hypertrons-crx' in configHypertrons) {
this.settings = await mergeSettings(configHypertrons['hypertrons-crx']);
} else {
this.settings = await loadSettings();
}
this.settings = await loadSettings();
} else {
this.settings = await loadSettings();
}
Expand Down Expand Up @@ -61,7 +49,7 @@ export class Perceptor extends PerceptorBase {
}
logger.info('running ', featureId);
const feature = new Feature();
await feature.run(this.hypertronsConfig);
await feature.run();
}, this);
}
}
Expand Down
46 changes: 0 additions & 46 deletions src/anchors/HypertronsAnchor.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions src/anchors/PerceptorTabAnchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import $ from 'jquery';
import { utils } from 'github-url-detection';
import { isPerceptor, runsWhen, isPublicRepo } from '../utils/utils';
import PerceptorBase from '../PerceptorBase';
import { render } from 'react-dom';
import React from 'react';
import TeachingBubbleWrapper from '../views/TeachingBubbleWrapperView/TeachingBubbleWrapperView';
import logger from '../utils/logger';

@runsWhen([isPublicRepo])
Expand Down Expand Up @@ -74,10 +71,6 @@ class PerceptorTabAnchor extends PerceptorBase {
}
}

// Deal with teaching bubble
const teaching_bubble = document.createElement('div');
$('.js-repo-pjax-container').prepend(teaching_bubble);

// Update
perceptorLink.attr(
'href',
Expand All @@ -92,7 +85,6 @@ class PerceptorTabAnchor extends PerceptorBase {
'<path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" d="M 14.253906 0 C 13.292969 0 12.507812 0.78125 12.507812 1.746094 C 12.507812 2.046875 12.585938 2.328125 12.71875 2.578125 L 9.859375 5.4375 C 9.464844 5.128906 8.972656 4.945312 8.4375 4.945312 C 7.898438 4.945312 7.40625 5.128906 7.011719 5.4375 L 4.78125 3.207031 C 4.882812 3.03125 4.945312 2.832031 4.945312 2.617188 C 4.945312 1.976562 4.421875 1.453125 3.78125 1.453125 C 3.140625 1.453125 2.617188 1.976562 2.617188 2.617188 C 2.617188 3.261719 3.140625 3.78125 3.78125 3.78125 C 3.996094 3.78125 4.195312 3.71875 4.371094 3.617188 L 6.601562 5.847656 C 6.292969 6.242188 6.109375 6.734375 6.109375 7.273438 C 6.109375 7.808594 6.292969 8.304688 6.601562 8.699219 L 2.917969 12.382812 C 2.605469 12.101562 2.195312 11.925781 1.746094 11.925781 C 0.78125 11.925781 0 12.710938 0 13.671875 C 0 14.636719 0.78125 15.417969 1.746094 15.417969 C 2.707031 15.417969 3.492188 14.636719 3.492188 13.671875 C 3.492188 13.371094 3.414062 13.089844 3.28125 12.839844 L 7.011719 9.109375 C 7.332031 9.359375 7.722656 9.527344 8.144531 9.578125 L 8.144531 12.535156 C 7.320312 12.675781 6.691406 13.390625 6.691406 14.253906 C 6.691406 15.21875 7.472656 16 8.4375 16 C 9.398438 16 10.183594 15.21875 10.183594 14.253906 C 10.183594 13.390625 9.550781 12.675781 8.726562 12.535156 L 8.726562 9.578125 C 9.152344 9.527344 9.539062 9.359375 9.863281 9.109375 L 12.09375 11.339844 C 11.988281 11.511719 11.925781 11.710938 11.925781 11.925781 C 11.925781 12.570312 12.449219 13.089844 13.089844 13.089844 C 13.734375 13.089844 14.253906 12.570312 14.253906 11.925781 C 14.253906 11.285156 13.734375 10.761719 13.089844 10.761719 C 12.875 10.761719 12.675781 10.828125 12.503906 10.929688 L 10.273438 8.699219 C 10.578125 8.304688 10.761719 7.808594 10.761719 7.273438 C 10.761719 6.734375 10.578125 6.242188 10.273438 5.847656 L 13.085938 3.035156 C 13.394531 3.316406 13.804688 3.492188 14.253906 3.492188 C 15.21875 3.492188 16 2.707031 16 1.746094 C 16 0.78125 15.21875 0 14.253906 0 Z M 3.199219 2.617188 C 3.199219 2.296875 3.460938 2.035156 3.78125 2.035156 C 4.101562 2.035156 4.363281 2.296875 4.363281 2.617188 C 4.363281 2.9375 4.101562 3.199219 3.78125 3.199219 C 3.460938 3.199219 3.199219 2.9375 3.199219 2.617188 Z M 1.746094 14.835938 C 1.105469 14.835938 0.582031 14.316406 0.582031 13.671875 C 0.582031 13.03125 1.105469 12.507812 1.746094 12.507812 C 2.386719 12.507812 2.910156 13.03125 2.910156 13.671875 C 2.910156 14.316406 2.386719 14.835938 1.746094 14.835938 Z M 9.601562 14.253906 C 9.601562 14.894531 9.078125 15.417969 8.4375 15.417969 C 7.792969 15.417969 7.273438 14.894531 7.273438 14.253906 C 7.273438 13.613281 7.792969 13.089844 8.4375 13.089844 C 9.078125 13.089844 9.601562 13.613281 9.601562 14.253906 Z M 8.4375 9.019531 C 7.472656 9.019531 6.691406 8.234375 6.691406 7.273438 C 6.691406 6.308594 7.472656 5.527344 8.4375 5.527344 C 9.398438 5.527344 10.183594 6.308594 10.183594 7.273438 C 10.183594 8.234375 9.398438 9.019531 8.4375 9.019531 Z M 13.671875 11.925781 C 13.671875 12.25 13.410156 12.507812 13.089844 12.507812 C 12.769531 12.507812 12.507812 12.25 12.507812 11.925781 C 12.507812 11.605469 12.769531 11.34375 13.089844 11.34375 C 13.410156 11.34375 13.671875 11.605469 13.671875 11.925781 Z M 14.253906 2.910156 C 13.613281 2.910156 13.089844 2.386719 13.089844 1.746094 C 13.089844 1.105469 13.613281 0.582031 14.253906 0.582031 C 14.894531 0.582031 15.417969 1.105469 15.417969 1.746094 C 15.417969 2.386719 14.894531 2.910156 14.253906 2.910156 Z M 14.253906 2.910156 "/>'
);

render(<TeachingBubbleWrapper target="#perceptor_tab" />, teaching_bubble);
insightsTab.after(perceptorTab);
}
}
Expand Down
18 changes: 5 additions & 13 deletions src/api/developer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { HYPERTRONS_OSS_XLAB_ENDPOINT, OSS_XLAB_ENDPOINT } from '../constant';
import request, { mockSuccessRes } from '../utils/request';
import {
developerCollabrationData,
participatedProjectsData,
} from '../mock/developer.data';
import request from '../utils/request';

// metric names and their implementation names in OpenDigger
const metricNameMap = new Map([
Expand All @@ -30,17 +26,13 @@ export const getOpenrank = async (user: string) => {

// the two requests below will be deprecated once their OpenDigger implementations are ready
export const getDeveloperCollabration = async (developer: string) => {
return (
mockSuccessRes(developerCollabrationData) ||
(await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}.json`))
return await request(
`${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}.json`
);
};

export const getParticipatedProjects = async (developer: string) => {
return (
mockSuccessRes(participatedProjectsData) ||
(await request(
`${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}_top.json`
))
return await request(
`${HYPERTRONS_OSS_XLAB_ENDPOINT}/actor/${developer}_top.json`
);
};
24 changes: 0 additions & 24 deletions src/api/github.ts

This file was deleted.

13 changes: 3 additions & 10 deletions src/api/repo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HYPERTRONS_OSS_XLAB_ENDPOINT, OSS_XLAB_ENDPOINT } from '../constant';
import request, { mockSuccessRes } from '../utils/request';
import { repoCorrelationData, developersByRepo } from '../mock/repo.data';
import request from '../utils/request';

// metric names and their implementation names in OpenDigger
const metricNameMap = new Map([
Expand Down Expand Up @@ -87,15 +86,9 @@ export const getMergedCodeSum = async (repo: string) => {

// the two requests below will be deprecated once their OpenDigger implementations are ready
export const getRepoCorrelation = async (repo: string) => {
return (
mockSuccessRes(repoCorrelationData) ||
(await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}.json`))
);
return await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}.json`);
};

export const getDevelopersByRepo = async (repo: string) => {
return (
mockSuccessRes(developersByRepo) ||
(await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}_top.json`))
);
return await request(`${HYPERTRONS_OSS_XLAB_ENDPOINT}/repo/${repo}_top.json`);
};
94 changes: 0 additions & 94 deletions src/components/DynamicRadar/ControlBar/ControlBar.tsx

This file was deleted.

Loading