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 github1s for supporting other scm #398

Merged
merged 77 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
5bc1959
chore: add type definations
conwnet Aug 3, 2021
a567c1c
chore: add type definations
conwnet Aug 5, 2021
c86ed9f
chore: add type definations
conwnet Aug 12, 2021
1c9ba01
chore: add type definations
conwnet Aug 18, 2021
222b47e
chore: add type definations
conwnet Aug 19, 2021
5b1e816
chore: add github1s adapter
conwnet Aug 19, 2021
ebade2a
chore: implements adapter
conwnet Aug 19, 2021
eb3b1f3
chore: add github1s adapter
conwnet Aug 20, 2021
e64285e
refactor: refact file system provider
conwnet Sep 15, 2021
b78273b
refactor: refact fileSystemProvider
conwnet Sep 15, 2021
27f9e88
refactor: fill github datasource
conwnet Sep 16, 2021
154b610
refactor: fill github datasource
conwnet Sep 16, 2021
9f13c69
refactor: fill github datasource
conwnet Sep 16, 2021
0dd7b70
refactor: fill github datasource
conwnet Sep 17, 2021
02becb4
refactor: text search provider
conwnet Sep 20, 2021
b125c14
refactor: definitions and references
conwnet Sep 21, 2021
68394b5
refactor: move settings code to adapters
conwnet Jan 9, 2022
fd8bc33
feat: add github1s adapter
conwnet Apr 3, 2022
766a2a9
refactor: refactor pull list view
conwnet Apr 5, 2022
8259d05
refactor: refactor commit list view
conwnet Apr 10, 2022
6ad833d
refactor: changed file provider
conwnet Apr 10, 2022
284ea34
refactor: definination provider and reference provider
conwnet Apr 10, 2022
1313cde
refactor: hover provider
conwnet Apr 10, 2022
bdd2c97
refactor: text search provider and file search provider
conwnet Apr 10, 2022
490e2b7
refactor: update provider files
conwnet Apr 10, 2022
bdc6abf
refactor: extension listeners
conwnet Apr 10, 2022
7bb0f23
refactor: editor and ref commands
conwnet Apr 12, 2022
2c13555
refactor: rename constants
conwnet Apr 12, 2022
8521c1a
refactor: use singleton repository
conwnet Apr 12, 2022
03d3906
refactor: blame commands
conwnet Apr 12, 2022
c7e8c1f
refactor: global commands
conwnet Apr 12, 2022
4772f8e
refactor: optimize file system provider
conwnet Apr 12, 2022
6d1e456
reafactor: clean entry files
conwnet Apr 12, 2022
9deb44f
reafactor: fix ts errors
conwnet Apr 12, 2022
c19ab38
reafactor: fix read submodule file
conwnet Apr 12, 2022
f93b740
rafactor: optimize director structure & fix chnaged files decoration
conwnet Apr 15, 2022
23b4ff1
feat: upgrade vscode to 1.66.2
conwnet Apr 15, 2022
04c85eb
feat: update initialize rule
conwnet Apr 15, 2022
9277beb
feat: update vscode deps and add workspace identifier
conwnet Apr 16, 2022
095147a
feat: update proload css
conwnet Apr 16, 2022
5326b90
feat: add auth command
conwnet Apr 16, 2022
581a625
feat: github oauth token
conwnet Apr 16, 2022
a0c8b52
feat: remove unused files
conwnet Apr 16, 2022
7ce0ad4
feat: update adapter context
conwnet Apr 16, 2022
7badb9f
feat: preload file structures
conwnet Apr 16, 2022
134964f
fix: css preload typo
conwnet Apr 16, 2022
553be7c
fix: connect to github and set token
conwnet Apr 16, 2022
dcae51a
refactor: remove vscode loader.js modification
conwnet Apr 17, 2022
24e7875
fix: invalid token status & localize webview libraries
conwnet Apr 17, 2022
11d3a19
feat: update dependencies & fix commit diff
conwnet Apr 17, 2022
6ab1b34
fix: token changed create wrong octokit
conwnet Apr 17, 2022
ffb4494
fix: data source types
conwnet Apr 17, 2022
de2d170
feat: add notifications & platform logos
conwnet Apr 18, 2022
2121878
feat: use sourcegraph api
conwnet Apr 18, 2022
e55257a
feat: update github1s fetcher retry rule
conwnet Apr 18, 2022
a4b2b5b
feat: remove prebuilt vscode-anycode
conwnet Apr 19, 2022
f2eced8
feat: remove prebuilt vscode-anycode
conwnet Apr 19, 2022
98c7689
feat: add sourcegraph api
conwnet May 5, 2022
44ea77d
feat: change settings page
conwnet May 5, 2022
90387d6
feat: auto switch github api
conwnet May 7, 2022
929197d
chore: update datasource & fix user avatar url
conwnet May 7, 2022
6c984fa
feat: fix vercel build script
conwnet May 7, 2022
3f1019f
fix: commit list refresh lost data
conwnet May 8, 2022
a1b1f0d
feat: commit list paginations
conwnet May 8, 2022
bf6d490
fix: commit manager load data
conwnet May 8, 2022
29a21c3
feat: increase text search count
conwnet May 8, 2022
3a4a958
feat: add list file recursively limit
conwnet May 8, 2022
e339a26
feat: add gitlab support
conwnet May 8, 2022
28cc68a
feat: add bitbucket support
conwnet May 8, 2022
cb3825b
fix: parse router path
conwnet May 9, 2022
990b1d6
default: use default branch for router parser in gitlab1s
conwnet May 9, 2022
1ab9b4a
feat: update default page title
conwnet May 9, 2022
9c0695f
feat: update logo link path
conwnet May 9, 2022
eb7952e
test: update test cases
conwnet May 9, 2022
b99380c
chore: update logo icon
conwnet May 9, 2022
9ad5d6f
ci: fix ci error
conwnet May 9, 2022
b9c7d5c
feat: update use sourcegraph api strategy
conwnet May 10, 2022
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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
**/lib/vscode/**
**/dist/**
**/src/vs/**
htm.module.js
preact.module.js
preact-hooks.module.js
10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
"extends": ["plugin:prettier/recommended"],
"plugins": ["@typescript-eslint", "jsdoc"],
"rules": {
"max-len": [
"error",
{
"code": 120,
"ignoreStrings": true,
"ignoreUrls": true,
"ignoreTemplateLiterals": true,
"ignoreComments": true
}
],
"constructor-super": "warn",
"curly": "warn",
"eqeqeq": "warn",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
node-version: [14.x, 15.x]
node-version: [14.x, 16.x]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-wtih-vscode-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
node-version: [14.x, 15.x]
node-version: [14.x, 16.x]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ lib
dist
out
node_modules
.yalc
yalc.lock
7 changes: 5 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ lib
dist
out
node_modules
vscode-web-github1s/src/vs
vscode-web-github1s/extensions
vscode-web/src/vs
vscode-web/extensions
htm.module.js
preact.module.js
preact-hooks.module.js
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
useTabs: true,
semi: true,
singleQuote: true,
printWidth: 120,
overrides: [
{
files: ['*.yml', '*.yaml', '*.json'],
Expand Down
11 changes: 4 additions & 7 deletions api/github-auth-callback/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ module.exports = async (req, res) => {

try {
// https://docs.github.com/en/developers/apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github
const response = await got.post(
'https://github.com/login/oauth/access_token',
{
json: { client_id: CLIENT_ID, client_secret: CLIENT_SECRET, code },
responseType: 'json',
}
);
const response = await got.post('https://github.com/login/oauth/access_token', {
json: { client_id: CLIENT_ID, client_secret: CLIENT_SECRET, code },
responseType: 'json',
});
return sendResponseHtml(response.statusCode, response.body);
} catch (e) {
// the error is responded by GitHub
Expand Down
5 changes: 1 addition & 4 deletions api/vscode-unpkg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ module.exports = async (req, res) => {
const requestUrl = `https://${publisher}.vscode-unpkg.net/${publisher}/${restPartsPath}`;
const responsePromise = got(requestUrl);
const bufferPromise = responsePromise.buffer();
const [response, buffer] = await Promise.all([
responsePromise,
bufferPromise,
]);
const [response, buffer] = await Promise.all([responsePromise, bufferPromise]);

res.status(response.statusCode);
res.setHeader('cache-control', response.headers['cache-control']);
Expand Down
6 changes: 3 additions & 3 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ What happens after you run `yarn watch-with-vscode`?

1. Copy some necessary resources (`index.html`, extensions config, libraries, etc.) to the `dist` directory.

2. Go to `vscode-web-github1s/lib/vscode` and run `yarn gulp compile-web` to build the necessary extensions, then copy it to the `dist/extensions` directory.
2. Go to `vscode-web/lib/vscode` and run `yarn gulp compile-web` to build the necessary extensions, then copy it to the `dist/extensions` directory.

3. Go to `vscode-web-github1s/lib/vscode` and run `yarn watch` (the native watch of vscode), it will trigger a new build if something in it has been changed.
3. Go to `vscode-web/lib/vscode` and run `yarn watch` (the native watch of vscode), it will trigger a new build if something in it has been changed.

4. Watch the `vscode-web-github1s/src` directory, merge it in to `vscode-web-github1s/lib/vscode/src` if something in it has been changed. (When a new file is merged into `lib/vscode/src`, it will trigger the watcher that is described in Step 3)
4. Watch the `vscode-web/src` directory, merge it in to `vscode-web/lib/vscode/src` if something in it has been changed. (When a new file is merged into `lib/vscode/src`, it will trigger the watcher that is described in Step 3)

5. Go to `extensions/github1s` and run `yarn watch`, it will trigger a new build if something has been changed.

Expand Down
164 changes: 164 additions & 0 deletions extensions/github1s/assets/pages/components.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
.vscode-button {
border: none;
display: inline-block;
padding: 0 10px;
height: 26px;
line-height: 26px;
font-size: 14px;
outline: 1px solid transparent;
outline-offset: 2px !important;
color: var(--vscode-button-foreground);
background: var(--vscode-button-background);
cursor: pointer;
}

.vscode-button.loading {
opacity: .5;
}

.vscode-button.size-mini {
padding: 0 8px;
height: 22px;
line-height: 22px;
font-size: 12px;
}

.vscode-button.size-middle {
padding: 0 12px;
height: 30px;
line-height: 30px;
font-size: 14px;
}

.vscode-button.size-large {
padding: 0 14px;
height: 34px;
line-height: 34px;
font-size: 18px;
}

.vscode-button:not([disabled]):hover {
background: var(--vscode-button-hoverBackground);
}

.vscode-button:not([disabled]):focus {
outline-color: var(--vscode-focusBorder);
}

.vscode-input {
border: none;
display: inline-block;
padding: 0 4px;
height: 26px;
line-height: 26px;
font-size: 13px;
outline: 1px solid transparent;
font-family: var(--vscode-font-family);
color: var(--vscode-input-foreground);
border: 1px solid var(--vscode-input-background);
background-color: var(--vscode-input-background);
}

.vscode-input.size-mini {
padding: 0 2px;
height: 22px;
line-height: 22px;
font-size: 12px;
}

.vscode-input.size-middle {
padding: 0 4px;
height: 30px;
line-height: 30px;
font-size: 13px;
}

.vscode-input.size-large {
padding: 0 6px;
height: 34px;
line-height: 34px;
font-size: 18px;
}

.vscode-input:not([disabled]):focus {
outline-color: var(--vscode-focusBorder);
outline: 1px solid -webkit-focus-ring-color;
outline-offset: -1px;
}

.vscode-textarea {
border: none;
display: inline-block;
outline: 1px solid transparent;
font-family: var(--vscode-font-family);
color: var(--vscode-input-foreground);
border: 1px solid var(--vscode-input-background);
background-color: var(--vscode-input-background);
}

.vscode-textarea:not([disabled]):focus {
outline-color: var(--vscode-focusBorder);
outline: 1px solid -webkit-focus-ring-color;
outline-offset: -1px;
}

.vscode-loading {
width: 100%;
text-align: center;
height: 26px;
}

.vscode-loading > span {
height: 100%;
width: 5px;
display: inline-block;
margin-right: 4px;
background: var(--vscode-button-background);
animation: vscodeLoading 1.2s infinite ease-in-out;
}

.vscode-loading > span:nth-child(2) {
animation-delay: -1s;
}

.vscode-loading > span:nth-child(3) {
animation-delay: -0.9s;
}

.vscode-loading > span:nth-child(4) {
animation-delay: -0.8s;
}

.vscode-loading > span:nth-child(5) {
margin-right: 0 !important;
animation-delay: -0.7s;
}

@keyframes vscodeLoading {
0% {
transform: scaleY(0.4);
}
25% {
transform: scaleY(1);
}
50% {
transform: scaleY(0.4);
}
75% {
transform: scaleY(0.4);
}
100% {
transform: scaleY(0.4);
}
}

.vscode-link {
cursor: pointer;
color: var(--vscode-textLink-foreground);
text-decoration: underline;
}

.vscode-link:hover {
color: var(--vscode-textLink-activeForeground);
}

58 changes: 58 additions & 0 deletions extensions/github1s/assets/pages/components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { h } from './preact.module.js';
import htm from './htm.module.js';

export const html = htm.bind(h);

export const VscodeButton = ({ size, loading, ...props }) => {
const sizeClass = `size-${size || 'small'}`;
const loadingClass = loading ? 'loading' : '';
const classes = `vscode-button ${sizeClass} ${loadingClass}`;

return html`<button class=${classes} disabled=${loading} ...${props} />`;
};

export const VscodeInput = ({ size, ...props }) => {
const classes = `vscode-input size-${size || 'small'}`;

return html`<input class=${classes} ...${props} />`;
};

export const VscodeTextarea = (props) => {
return html` <textarea class="vscode-textarea" ...${props} /> `;
};

export const VscodeLoading = ({ blockWidth, blockSpacing, ...props }) => {
const _blockWidth = blockWidth || '5px';
const _blockSpacing = blockSpacing || '4px';
const styleStr = `width: ${_blockWidth}; margin-right: ${_blockSpacing}`;
const blocks = Array.from({ length: 5 }).map(() => html`<span style=${styleStr} />`);

return html`<div class="vscode-loading" ...${props}>${blocks}</div>`;
};

export const VscodeLink = ({ to, external, ...props }) => {
const hrefProp = to ? { href: to } : {};
const roleProp = to ? {} : { role: 'button' };
const targetProp = external ? { target: '_blank' } : {};
const combineProps = { ...hrefProp, ...roleProp, ...targetProp };

return html` <a class="vscode-link" ...${combineProps} ...${props} /> `;
};

export const postMessage = (() => {
const vscode = window.acquireVsCodeApi();
const uniqueId = ((id) => () => id++)(1);
const messageMap = new Map();

window.addEventListener('message', ({ data }) => {
messageMap.has(data.id) && messageMap.get(data.id)(data.data);
});

return (type, data) => {
const messageId = uniqueId();
vscode.postMessage({ type, data, id: messageId });
return new Promise((resolve) => {
messageMap.set(messageId, resolve);
});
};
})();
Loading