Skip to content

Commit

Permalink
Merge pull request #459 from conwnet/master
Browse files Browse the repository at this point in the history
release 0.10.0
  • Loading branch information
conwnet authored Nov 6, 2022
2 parents c3737bb + 0c25967 commit 257a0fd
Show file tree
Hide file tree
Showing 23 changed files with 793 additions and 731 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
//"postCreateCommand": "yarn",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node",
"remoteUser": "node"
}
13 changes: 11 additions & 2 deletions extensions/github1s/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"private": true,
"enabledApiProposals": [
"fileSearchProvider",
"textSearchProvider"
"textSearchProvider",
"resolvers"
],
"directories": {
"lib": "lib"
Expand All @@ -16,7 +17,10 @@
"onFileSystem:gitlab1s",
"onFileSystem:bitbucket1s",
"onFileSystem:npmjs1s",
"onFileSystem:ossinsight"
"onFileSystem:ossinsight",
"onCommand:remoteHub.openRepository",
"onCommand:github1s.commands.openRepository",
"onStartupFinished"
],
"browser": "./dist/extension",
"engines": {
Expand Down Expand Up @@ -65,6 +69,11 @@
"title": "Open Repository...",
"category": "GitHub1s"
},
{
"command": "github1s.commands.openOnlineEditor",
"title": "Open Online Editor...",
"category": "GitHub1s"
},
{
"command": "github1s.commands.checkoutTo",
"title": "Checkout to...",
Expand Down
9 changes: 9 additions & 0 deletions extensions/github1s/src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ import { GitLab1sAdapter } from './gitlab1s';
import { BitbucketAdapter } from './bitbucket1s';
import { Npmjs1sAdapter } from './npmjs1s';
import { OSSInsightAdapter } from './ossinsight';
import { DataSource, PlatformName, RouterParser } from './types';

const emptyAdapter = {
scheme: 'empty',
platformName: PlatformName.GitHub,
resolveDataSource: () => new DataSource(),
resolveRouterParser: () => new RouterParser(),
};

export const registerAdapters = async (): Promise<void> => {
await Promise.all([
adapterManager.registerAdapter(emptyAdapter),
adapterManager.registerAdapter(new GitHub1sAdapter()),
adapterManager.registerAdapter(new GitLab1sAdapter()),
adapterManager.registerAdapter(new BitbucketAdapter()),
Expand Down
5 changes: 1 addition & 4 deletions extensions/github1s/src/adapters/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ export class AdapterManager {
}

public getCurrentScheme(): string {
if (!vscode.workspace.workspaceFolders?.length) {
throw new Error(`Can not found active workspace`);
}
return vscode.workspace.workspaceFolders[0].uri.scheme;
return vscode.workspace.workspaceFolders?.[0]?.uri?.scheme || 'empty';
}

public getCurrentAdapter(): Adapter {
Expand Down
16 changes: 8 additions & 8 deletions extensions/github1s/src/adapters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,43 +345,43 @@ export type RouterState = { repo: string; ref: string } & (
export class RouterParser {
// parse giving path (starts with '/', may includes search and hash) to Router state,
parsePath(path: string): Promisable<RouterState> {
return { repo: 'conwnet/github1s', ref: 'HEAD', pageType: PageType.Tree, filePath: '' };
return { repo: '', ref: 'HEAD', pageType: PageType.Tree, filePath: '' };
}

// build the tree page path
buildTreePath(repo: string, ref?: string, filePath?: string): Promisable<string> {
return '/conwnet/github1s';
return '/' + repo;
}

// build the blob page path
// startLine/endLine begins from 1
// eslint-disable-next-line max-len
buildBlobPath(repo: string, ref: string, filePath: string, startLine?: number, endLine?: number): Promisable<string> {
return '/conwnet/github1s';
return '/' + repo;
}
// build the commit list page path
buildCommitListPath(repo: string): Promisable<string> {
return '/conwnet/github1s';
return '/' + repo;
}

// build the commit page path
buildCommitPath(repo: string, commitSha: string): Promisable<string> {
return '/conwnet/github1s';
return '/' + repo;
}

// build the code review list page path
buildCodeReviewListPath(repo: string): Promisable<string> {
return '/conwnet/github1s';
return '/' + repo;
}

// build the code review page path
buildCodeReviewPath(repo: string, codeReviewId: string): Promisable<string> {
return '/conwnet/github1s';
return '/' + repo;
}

// convert giving path to the external link (using for jumping back to origin platform)
buildExternalLink(path: string): Promisable<string> {
return '/conwnet/github1s';
return 'https://github.com' + path;
}
}

Expand Down
15 changes: 12 additions & 3 deletions extensions/github1s/src/commands/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,21 @@ export const commandOpenRepository = async () => {
quickPick.onDidAccept(async () => {
const choice = quickPick.activeItems[0];
const repository = choice === manualInputItem ? quickPick.value : choice.label;
const tagetLink = vscode.Uri.parse((await router.href()) || '').with({
const targetLink = vscode.Uri.parse((await router.href()) || '').with({
path: await (await router.resolveParser()).buildTreePath(repository),
});
vscode.commands.executeCommand('vscode.open', tagetLink);
vscode.commands.executeCommand('vscode.open', targetLink);
quickPick.hide();
});
};

const commandOpenOnlineEditor = async () => {
const currentScheme = adapterManager.getCurrentScheme();
const onlineEditorPath = ['github1s', 'ossinsight'].includes(currentScheme) ? '/editor' : '/';
const targetLink = vscode.Uri.parse((await router.href()) || '').with({ path: onlineEditorPath });
return vscode.commands.executeCommand('vscode.open', targetLink);
};

export const registerGlobalCommands = (context: vscode.ExtensionContext) => {
return context.subscriptions.push(
vscode.commands.registerCommand('github1s.commands.openOnGitHub', commandOpenOnOfficialPage),
Expand All @@ -85,6 +92,8 @@ export const registerGlobalCommands = (context: vscode.ExtensionContext) => {
vscode.commands.registerCommand('github1s.commands.openOnNpm', commandOpenOnOfficialPage),
vscode.commands.registerCommand('github1s.commands.openOnOfficialPage', commandOpenOnOfficialPage),
vscode.commands.registerCommand('github1s.commands.openOnGitPod', commandOpenGitpod),
vscode.commands.registerCommand('github1s.commands.openRepository', commandOpenRepository)
vscode.commands.registerCommand('github1s.commands.openRepository', commandOpenRepository),
vscode.commands.registerCommand('github1s.commands.openOnlineEditor', commandOpenOnlineEditor),
vscode.commands.registerCommand('remoteHub.openRepository', commandOpenRepository)
);
};
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
"lib": "lib"
},
"devDependencies": {
"@github1s/vscode-web": "0.5.0",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"@github1s/vscode-web": "0.6.0",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"chokidar": "^3.5.3",
"copy-webpack-plugin": "^11.0.0",
"eslint": "^8.17.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsdoc": "^39.3.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-jsdoc": "^39.3.14",
"eslint-plugin-prettier": "^4.2.1",
"fs-extra": "^10.1.0",
"generate-file-webpack-plugin": "^1.0.1",
"html-webpack-plugin": "^5.5.0",
"http-proxy": "^1.18.1",
"husky": "^8.0.1",
"lint-staged": "^13.0.1",
"lint-staged": "^13.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.0",
"prettier": "^2.7.1",
"serve-handler": "^6.1.3",
"start-server-and-test": "^1.14.0",
"typescript": "^4.7.3",
Expand Down
Loading

1 comment on commit 257a0fd

@vercel
Copy link

@vercel vercel bot commented on 257a0fd Nov 6, 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.