Skip to content

Commit

Permalink
Merge pull request #425 from conwnet/master
Browse files Browse the repository at this point in the history
release 0.8.0
  • Loading branch information
conwnet authored Jun 25, 2022
2 parents 86f63da + 2e184ec commit 6bb61e5
Show file tree
Hide file tree
Showing 71 changed files with 6,048 additions and 6,168 deletions.
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, 16.x]
node-version: [16.x, 18.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, 16.x]
node-version: [16.x]

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

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ git clone [email protected]:conwnet/github1s.git
cd github1s
yarn
yarn watch
yarn serve # in another shell
# Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
# The cli will automatically open http://localhost:5000 once the build is completed.
# You can visit http://localhost:5000/conwnet/github1s if it doesn't.
```

#### Local development with full VS Code build
Expand All @@ -84,8 +84,8 @@ After the inital successful build, you could use the watch mode:
cd github1s
yarn
yarn watch-with-vscode
yarn serve # in another shell
# Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
# The cli will automatically open http://localhost:5000 once the build is completed.
# You can visit http://localhost:5000/conwnet/github1s if it doesn't.
```

### ... or ... VS Code + Docker Development
Expand All @@ -104,8 +104,8 @@ You can use the VS Code plugin [Remote-Containers](https://marketplace.visualstu
```bash
yarn
yarn watch
yarn serve # in another shell
# Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
# The cli will automatically open http://localhost:5000 once the build is completed.
# You can visit http://localhost:5000/conwnet/github1s if it doesn't.
```

### Format all codes
Expand Down
2 changes: 1 addition & 1 deletion api/github-auth-callback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"license": "MIT",
"private": true,
"dependencies": {
"got": "^11.8.2"
"got": "^11.8.5"
}
}
28 changes: 14 additions & 14 deletions api/github-auth-callback/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ cacheable-lookup@^5.0.3:
resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005"
integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==

cacheable-request@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.1.tgz#062031c2856232782ed694a257fa35da93942a58"
integrity sha512-lt0mJ6YAnsrBErpTMWeu5kl/tg9xMAWjavYTN6VQXM1A/teBITuNcccXsCxF0tDQQJf9DfAaX5O4e0zp0KlfZw==
cacheable-request@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27"
integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==
dependencies:
clone-response "^1.0.2"
get-stream "^5.1.0"
http-cache-semantics "^4.0.0"
keyv "^4.0.0"
lowercase-keys "^2.0.0"
normalize-url "^4.1.0"
normalize-url "^6.0.1"
responselike "^2.0.0"

clone-response@^1.0.2:
Expand Down Expand Up @@ -99,17 +99,17 @@ get-stream@^5.1.0:
dependencies:
pump "^3.0.0"

got@^11.8.2:
version "11.8.2"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.2.tgz#7abb3959ea28c31f3576f1576c1effce23f33599"
integrity sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==
got@^11.8.5:
version "11.8.5"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.5.tgz#ce77d045136de56e8f024bebb82ea349bc730046"
integrity sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==
dependencies:
"@sindresorhus/is" "^4.0.0"
"@szmarczak/http-timer" "^4.0.5"
"@types/cacheable-request" "^6.0.1"
"@types/responselike" "^1.0.0"
cacheable-lookup "^5.0.3"
cacheable-request "^7.0.1"
cacheable-request "^7.0.2"
decompress-response "^6.0.0"
http2-wrapper "^1.0.0-beta.5.2"
lowercase-keys "^2.0.0"
Expand Down Expand Up @@ -156,10 +156,10 @@ mimic-response@^3.1.0:
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9"
integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==

normalize-url@^4.1.0:
version "4.5.1"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a"
integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==
normalize-url@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a"
integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==

once@^1.3.1, once@^1.4.0:
version "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion api/vscode-unpkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"license": "MIT",
"private": true,
"dependencies": {
"got": "^11.8.2"
"got": "^11.8.5"
}
}
12 changes: 6 additions & 6 deletions api/vscode-unpkg/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ cacheable-lookup@^5.0.3:
resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005"
integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==

cacheable-request@^7.0.1:
cacheable-request@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27"
integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew==
Expand Down Expand Up @@ -99,17 +99,17 @@ get-stream@^5.1.0:
dependencies:
pump "^3.0.0"

got@^11.8.2:
version "11.8.2"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.2.tgz#7abb3959ea28c31f3576f1576c1effce23f33599"
integrity sha512-D0QywKgIe30ODs+fm8wMZiAcZjypcCodPNuMz5H9Mny7RJ+IjJ10BdmGW7OM7fHXP+O7r6ZwapQ/YQmMSvB0UQ==
got@^11.8.5:
version "11.8.5"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.5.tgz#ce77d045136de56e8f024bebb82ea349bc730046"
integrity sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==
dependencies:
"@sindresorhus/is" "^4.0.0"
"@szmarczak/http-timer" "^4.0.5"
"@types/cacheable-request" "^6.0.1"
"@types/responselike" "^1.0.0"
cacheable-lookup "^5.0.3"
cacheable-request "^7.0.1"
cacheable-request "^7.0.2"
decompress-response "^6.0.0"
http2-wrapper "^1.0.0-beta.5.2"
lowercase-keys "^2.0.0"
Expand Down
4 changes: 2 additions & 2 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ $ yarn
$ yarn watch # or yarn build, it may take minutes, wait please
```

Then, there will be a new directory named `dist` generated in the project root. You can run `yarn serve` in another shell, and it will create a static file server for the `dist` directory.
Then, there will be a new directory named `dist` generated in the project root. The `yarn watch:dev-server` (part of `yarn watch` command) will automatically open http://localhost:5000 in the browser.

Now you can visit http://localhost:5000 in the browser. If you get a 404 error for some static files, please wait a minute for the building to complete.
If you get a 404 error for some static files, please wait a minute for the building to complete.

## Watch Mode

Expand Down
5 changes: 4 additions & 1 deletion extensions/github1s/assets/pages/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export const VscodeLink = ({ to, external, ...props }) => {

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

window.addEventListener('message', ({ data }) => {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/blame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BlameRange } from '../types';
import { querySourcegraphRepository } from './common';

const BlameRangesQuery = gql`
query($repository: String!, $ref: String!, $path: String!) {
query ($repository: String!, $ref: String!, $path: String!) {
repository(name: $repository) {
commit(rev: $ref) {
blob(path: $path) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/comparison.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ChangedFile, FileChangeStatus } from '../types';
import { querySourcegraphRepository } from './common';

const ComparisonQuery = gql`
query($repository: String!, $base: String!, $head: String!) {
query ($repository: String!, $base: String!, $head: String!) {
repository(name: $repository) {
comparison(base: $base, head: $head) {
fileDiffs {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getSymbolPositions } from './position';
import { SymbolDefinitions } from '../types';

const LSIFDefinitionsQuery = gql`
query($repository: String!, $ref: String!, $path: String!, $line: Int!, $character: Int!) {
query ($repository: String!, $ref: String!, $path: String!, $line: Int!, $character: Int!) {
repository(name: $repository) {
commit(rev: $ref) {
blob(path: $path) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const readDirectory = async (
};

const FileQuery = gql`
query($repository: String!, $ref: String!, $path: String!) {
query ($repository: String!, $ref: String!, $path: String!) {
repository(name: $repository) {
commit(rev: $ref) {
blob(path: $path) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SymbolHover } from '../types';
import { sourcegraphClient } from './common';

const LSIFHoverQuery = gql`
query($repository: String!, $ref: String!, $path: String!, $line: Int!, $character: Int!) {
query ($repository: String!, $ref: String!, $path: String!, $line: Int!, $character: Int!) {
repository(name: $repository) {
commit(rev: $ref) {
blob(path: $path) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { escapeRegexp, sourcegraphClient } from './common';
import { CodeLocation } from '../types';

const searchPositionsQuery = gql`
query($query: String!) {
query ($query: String!) {
search(query: $query) {
results {
results {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { querySourcegraphRepository } from './common';
import { Branch, Tag } from '../types';

const BranchTagQuery = gql`
query($repository: String!) {
query ($repository: String!) {
repository(name: $repository) {
branches {
nodes {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getSymbolPositions } from './position';
import { SymbolReferences } from '../types';

const LSIFReferencesQuery = gql`
query($repository: String!, $ref: String!, $path: String!, $line: Int!, $character: Int!) {
query ($repository: String!, $ref: String!, $path: String!, $line: Int!, $character: Int!) {
repository(name: $repository) {
commit(rev: $ref) {
blob(path: $path) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { gql } from '@apollo/client/core';
import { sourcegraphClient } from './common';

const RepositoryQuery = gql`
query($repository: String!) {
query ($repository: String!) {
repository(name: $repository) {
name
defaultBranch {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const buildTextSearchQueryString = (
};

const textSearchQuery = gql`
query($query: String!) {
query ($query: String!) {
search(query: $query) {
results {
__typename
Expand Down
4 changes: 2 additions & 2 deletions extensions/github1s/src/adapters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ export type RouterState = { repo: string; ref: string } & (
| { pageType: PageType.CommitList } // for commit list page
| { pageType: PageType.Commit; commitSha: string } // for commit detail page
| { pageType: PageType.CodeReviewList } // for code review list page
| { pageType: PageType.CodeReview; codeReviewId: string } // for code review detail page
);
| { pageType: PageType.CodeReview; codeReviewId: string }
); // for code review detail page

export class RouterParser {
// parse giving path (starts with '/', may includes search and hash) to Router state,
Expand Down
5 changes: 4 additions & 1 deletion extensions/github1s/src/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export const basename = (path: string): string => {
return trimmedPath.substr(trimmedPath.lastIndexOf('/') + 1) || '';
};

export const uniqueId = ((id) => () => id++)(1);
export const uniqueId = (
(id) => () =>
id++
)(1);

export const prop = (obj: object, path: (string | number)[] = []): any => {
let cur = obj;
Expand Down
48 changes: 23 additions & 25 deletions extensions/github1s/src/providers/file-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,32 @@ export class GitHub1sFileSearchProvider implements FileSearchProvider, Disposabl
* we should not insert the response to the fileSystemProvider's
* cache, and the fuzzy search maybe not work fine
*/
getFileUris = reuseable(
async (authority: string): Promise<Uri[]> => {
if (this.fileUrisMap.has(authority)) {
return this.fileUrisMap.get(authority)!;
}

const [repo, ref] = authority.split('+');
const currentAdapter = adapterManager.getCurrentAdapter();
const dataSource = await currentAdapter.resolveDataSource();
const rootDirectoryData = await dataSource.provideDirectory(repo, ref, '', true);
const rootDirectoryUri = Uri.parse('').with({ scheme: currentAdapter.scheme, authority, path: '/' });
getFileUris = reuseable(async (authority: string): Promise<Uri[]> => {
if (this.fileUrisMap.has(authority)) {
return this.fileUrisMap.get(authority)!;
}

// the number of items in the tree array maybe exceeded maximum limit, only
// insert the data to fileSystemProvider's cache if `treeData.truncated` is false
if (!rootDirectoryData?.truncated) {
const fsProvider = GitHub1sFileSystemProvider.getInstance();
fsProvider.populateWithDirectoryEntities(rootDirectoryUri, rootDirectoryData?.entries || []);
} else {
window.showWarningMessage('Too many files in this repository, file search feature may be limited.');
}
const [repo, ref] = authority.split('+');
const currentAdapter = adapterManager.getCurrentAdapter();
const dataSource = await currentAdapter.resolveDataSource();
const rootDirectoryData = await dataSource.provideDirectory(repo, ref, '', true);
const rootDirectoryUri = Uri.parse('').with({ scheme: currentAdapter.scheme, authority, path: '/' });

const fileUris = (rootDirectoryData?.entries || [])
.filter((item) => item.type === adapterTypes.FileType.File)
.map((item) => Uri.joinPath(rootDirectoryUri, item.path));
this.fileUrisMap.set(authority, fileUris);
return fileUris;
// the number of items in the tree array maybe exceeded maximum limit, only
// insert the data to fileSystemProvider's cache if `treeData.truncated` is false
if (!rootDirectoryData?.truncated) {
const fsProvider = GitHub1sFileSystemProvider.getInstance();
fsProvider.populateWithDirectoryEntities(rootDirectoryUri, rootDirectoryData?.entries || []);
} else {
window.showWarningMessage('Too many files in this repository, file search feature may be limited.');
}
);

const fileUris = (rootDirectoryData?.entries || [])
.filter((item) => item.type === adapterTypes.FileType.File)
.map((item) => Uri.joinPath(rootDirectoryUri, item.path));
this.fileUrisMap.set(authority, fileUris);
return fileUris;
});

provideFileSearchResults(
query: FileSearchQuery,
Expand Down
Loading

1 comment on commit 6bb61e5

@vercel
Copy link

@vercel vercel bot commented on 6bb61e5 Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.