Skip to content

Commit db5740f

Browse files
committed
feat: adjust the code structure in extensions/github1s
1 parent 0b0254b commit db5740f

23 files changed

Lines changed: 798 additions & 686 deletions

extensions/github1s/extension.webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ module.exports = /** @type WebpackConfig */ {
2121
resolve: {
2222
mainFields: ['module', 'main'],
2323
extensions: ['.ts', '.js'], // support ts-files and js-files
24+
alias: {
25+
'@': path.resolve(__dirname, 'src'),
26+
},
2427
},
2528
module: {
2629
rules: [

extensions/github1s/src/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
*/
55

66
import * as vscode from 'vscode';
7+
import { getExtensionContext } from '@/helpers/context';
78
import {
8-
getExtensionContext,
99
getRepositoryBranchRefs,
1010
getRepositoryTagRefs,
1111
getCurrentRef,
1212
getCurrentAuthority,
1313
changeCurrentRef,
14-
} from './util';
15-
import { validateToken } from './api';
14+
} from '@/helpers/git-ref';
15+
import { validateToken } from '@/interfaces/github-api-rest';
1616

1717
export const commandValidateToken = (silent: boolean = false) => {
1818
const context = getExtensionContext();

extensions/github1s/src/extension.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,59 @@
44
*/
55

66
import * as vscode from 'vscode';
7-
import { GitHub1sFS } from './github1sfs';
8-
import { SettingsView } from './settings-view';
9-
import { setExtensionContext } from './util';
7+
import { SettingsView } from '@/views/settings-view';
8+
import { setExtensionContext } from '@/helpers/context';
109
import {
1110
commandUpdateToken,
1211
commandValidateToken,
1312
commandClearToken,
1413
commandSwitchBranch,
1514
commandSwitchTag,
1615
commandGetCurrentAuthority,
17-
} from './commands';
16+
} from '@/commands';
17+
import {
18+
GitHub1sFileSystemProvider,
19+
GitHub1sFileSearchProvider,
20+
GitHub1sTextSearchProvider,
21+
GitHub1sSubmoduleDecorationProvider,
22+
} from '@/providers';
1823

1924
export function activate(context: vscode.ExtensionContext) {
2025
setExtensionContext(context);
21-
context.subscriptions.push(new GitHub1sFS());
2226

27+
// providers
28+
const fsProvider = new GitHub1sFileSystemProvider();
29+
context.subscriptions.push(
30+
vscode.workspace.registerFileSystemProvider(
31+
GitHub1sFileSystemProvider.scheme,
32+
fsProvider,
33+
{
34+
isCaseSensitive: true,
35+
isReadonly: true,
36+
}
37+
),
38+
vscode.workspace.registerFileSearchProvider(
39+
GitHub1sFileSearchProvider.scheme,
40+
new GitHub1sFileSearchProvider(fsProvider)
41+
),
42+
vscode.workspace.registerTextSearchProvider(
43+
GitHub1sTextSearchProvider.scheme,
44+
new GitHub1sTextSearchProvider()
45+
),
46+
vscode.window.registerFileDecorationProvider(
47+
new GitHub1sSubmoduleDecorationProvider(fsProvider)
48+
)
49+
);
50+
51+
// views
2352
context.subscriptions.push(
2453
vscode.window.registerWebviewViewProvider(
2554
SettingsView.viewType,
2655
new SettingsView()
2756
)
2857
);
2958

59+
// commands
3060
context.subscriptions.push(
3161
vscode.commands.registerCommand(
3262
'github1s.validate-token',

0 commit comments

Comments
 (0)