Skip to content

Commit 7b60d54

Browse files
authored
chore: update opensumi 2.26.8 (#19)
* feat: update opensumi 2.26.8 * feat: plugin support afterExecuteCommand * fix: extensions load * chore: update version
1 parent 18c51cf commit 7b60d54

27 files changed

Lines changed: 697 additions & 472 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"description": "codeblitzjs",
99
"main": "index.js",
1010
"engines": {
11-
"opensumi": "2.23.0"
11+
"opensumi": "2.26.8"
1212
},
1313
"scripts": {
1414
"prepare": "husky install",

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"scripts": {},
1717
"dependencies": {
1818
"@codeblitzjs/ide-common": "1.0.3",
19-
"@opensumi/ide-extension": "2.23.0",
19+
"@opensumi/ide-extension": "2.26.8",
2020
"commander": "^7.2.0",
2121
"fs-extra": "^9.0.1",
2222
"lodash.flatten": "^4.4.0",

packages/cli/src/extension/scanner.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function getExtension(
3535
const packageJSON = await fse.readJSON(pkgPath);
3636
if (!packageJSON.engines) {
3737
pkgCheckResult = false;
38-
} else if (!(packageJSON.engines.vscode || packageJSON.engines.opensumi)) {
38+
} else if (!(packageJSON.engines.vscode || packageJSON.engines.kaitian)) {
3939
pkgCheckResult = false;
4040
}
4141
} catch (e) {
@@ -106,9 +106,13 @@ export async function getExtension(
106106
}
107107
}
108108

109-
// merge for `kaitianContributes` and `contributes`
109+
if (!packageJSON.sumiContributes && packageJSON.kaitianContributes) {
110+
packageJSON.sumiContributes = packageJSON.kaitianContributes;
111+
}
112+
113+
// merge for `sumiContributes` and `contributes`
110114
packageJSON.contributes = mergeContributes(
111-
packageJSON.kaitianContributes,
115+
packageJSON.sumiContributes,
112116
packageJSON.contributes
113117
);
114118

@@ -137,7 +141,7 @@ export async function getExtension(
137141
'description',
138142
'icon',
139143
'activationEvents',
140-
'kaitianContributes',
144+
'sumiContributes',
141145
'contributes',
142146
'browser',
143147
]),

packages/code-api/src/github/github.service.ts

Lines changed: 83 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { retry, RetryError } from '../common/utils';
1010
import {
1111
ICodeAPIService,
1212
TreeEntry,
13-
EntryParam,
14-
IRepositoryModel,
1513
BranchOrTag,
1614
CommitParams,
1715
CommitFileChange,
@@ -24,6 +22,7 @@ import {
2422
FileOperateResult,
2523
FileActionType,
2624
} from '../common/types';
25+
import type { IRepositoryModel, EntryParam } from '../common/types';
2726
import { CodePlatform, CommitFileStatus, CodeAPI as ConflictAPI } from '../common/types';
2827
import { CODE_PLATFORM_CONFIG } from '../common/config';
2928

@@ -77,7 +76,13 @@ export class GitHubAPIService implements ICodeAPIService {
7776
constructor() {
7877
this._OAUTH_TOKEN = this.config.token || this.helper.GITHUB_TOKEN;
7978
}
80-
createPullRequest(repo: IRepositoryModel, sourceBranch: string, targetBranch: string, title: string, autoMerge?: boolean | undefined): Promise<ConflictAPI.ResponseCreatePR> {
79+
createPullRequest(
80+
repo: IRepositoryModel,
81+
sourceBranch: string,
82+
targetBranch: string,
83+
title: string,
84+
autoMerge?: boolean | undefined
85+
): Promise<ConflictAPI.ResponseCreatePR> {
8186
throw new Error('Method not implemented.');
8287
}
8388
mergeBase(
@@ -127,15 +132,15 @@ export class GitHubAPIService implements ICodeAPIService {
127132
};
128133
}
129134
async createBranch(repo: IRepositoryModel, newBranch: string, ref: string): Promise<Branch> {
130-
const data = await this.rest.createReference(repo, newBranch, ref)
135+
const data = await this.rest.createReference(repo, newBranch, ref);
131136

132137
return {
133138
name: newBranch,
134139
ref: data.ref,
135140
commit: {
136-
id: data.object.sha
141+
id: data.object.sha,
137142
},
138-
}
143+
};
139144
}
140145
async available() {
141146
const token = this._OAUTH_TOKEN;
@@ -341,7 +346,11 @@ export class GitHubAPIService implements ICodeAPIService {
341346
});
342347
},
343348

344-
createTree: async (repo: IRepositoryModel, trees: API.RequestCreateTree[], base_tree?: string) => {
349+
createTree: async (
350+
repo: IRepositoryModel,
351+
trees: API.RequestCreateTree[],
352+
base_tree?: string
353+
) => {
345354
const data = await this.requestByREST<API.ResponseGetTree>(
346355
`/repos/${this.getProjectPath(repo)}/git/trees`,
347356
{
@@ -353,7 +362,7 @@ export class GitHubAPIService implements ICodeAPIService {
353362
data: {
354363
base_tree,
355364
tree: trees,
356-
}
365+
},
357366
}
358367
);
359368

@@ -391,7 +400,10 @@ export class GitHubAPIService implements ICodeAPIService {
391400
return data.tree.filter((item) => item.type === 'blob').map((item) => item.path);
392401
},
393402

394-
createBlob: async (repo: IRepositoryModel, blob: { content: string, encoding?: 'utf-8' | 'base64' }) => {
403+
createBlob: async (
404+
repo: IRepositoryModel,
405+
blob: { content: string; encoding?: 'utf-8' | 'base64' }
406+
) => {
395407
const data = await this.requestByREST<API.ResponseCreateBlob>(
396408
`/repos/${this.getProjectPath(repo)}/git/blobs`,
397409
{
@@ -403,7 +415,7 @@ export class GitHubAPIService implements ICodeAPIService {
403415
data: {
404416
content: blob.content,
405417
encoding: blob.encoding || 'utf-8',
406-
}
418+
},
407419
}
408420
);
409421

@@ -442,46 +454,60 @@ export class GitHubAPIService implements ICodeAPIService {
442454
},
443455

444456
createReference: async (repo: IRepositoryModel, ref: string, sha: string) => {
445-
const data = await this.requestByREST<API.ResponseReference>(`/repos/${this.getProjectPath(repo)}/git/refs`, {
446-
responseType: 'json',
447-
method: 'post',
448-
data: {
449-
ref: `refs/heads/${ref}`,
450-
sha
457+
const data = await this.requestByREST<API.ResponseReference>(
458+
`/repos/${this.getProjectPath(repo)}/git/refs`,
459+
{
460+
responseType: 'json',
461+
method: 'post',
462+
data: {
463+
ref: `refs/heads/${ref}`,
464+
sha,
465+
},
451466
}
452-
});
467+
);
453468

454-
return data
469+
return data;
455470
},
456471

457-
updateReference: async (repo: IRepositoryModel, ref: string, sha: string, force: boolean = false) => {
472+
updateReference: async (
473+
repo: IRepositoryModel,
474+
ref: string,
475+
sha: string,
476+
force: boolean = false
477+
) => {
458478
// 去掉开头的 refs/
459479
ref = ref.replace(/^refs\//, '');
460480
ref = ref.startsWith('heads') ? ref : `heads/${ref}`;
461481

462-
const data = await this.requestByREST<API.ResponseReference>(`/repos/${this.getProjectPath(repo)}/git/refs/${ref}`, {
463-
responseType: 'json',
464-
method: 'post',
465-
data: {
466-
sha,
467-
force
482+
const data = await this.requestByREST<API.ResponseReference>(
483+
`/repos/${this.getProjectPath(repo)}/git/refs/${ref}`,
484+
{
485+
responseType: 'json',
486+
method: 'post',
487+
data: {
488+
sha,
489+
force,
490+
},
468491
}
469-
});
492+
);
470493

471-
return data
494+
return data;
472495
},
473496

474497
getReference: async (repo: IRepositoryModel, ref: string) => {
475-
const data = await this.requestByREST<API.ResponseReference>(`/repos/${this.getProjectPath(repo)}/git/ref/${ref}`, {
476-
headers: {
477-
Accept: 'application/vnd.github+json',
478-
'X-GitHub-Api-Version': '2022-11-28'
479-
},
480-
responseType: 'json',
481-
method: 'get',
482-
});
498+
const data = await this.requestByREST<API.ResponseReference>(
499+
`/repos/${this.getProjectPath(repo)}/git/ref/${ref}`,
500+
{
501+
headers: {
502+
Accept: 'application/vnd.github+json',
503+
'X-GitHub-Api-Version': '2022-11-28',
504+
},
505+
responseType: 'json',
506+
method: 'get',
507+
}
508+
);
483509

484-
return data
510+
return data;
485511
},
486512

487513
getBranches: async (repo: IRepositoryModel): Promise<BranchOrTag[]> => {
@@ -829,26 +855,28 @@ export class GitHubAPIService implements ICodeAPIService {
829855

830856
// 先获取分支名
831857
// by CODE_SERVICE_COMMANDS
832-
const repositoryInfo: IRepositoryModel | undefined = await this.commandService.executeCommand('code-service.repository');
858+
const repositoryInfo: IRepositoryModel | undefined = await this.commandService.executeCommand(
859+
'code-service.repository'
860+
);
833861
if (!repositoryInfo || !repositoryInfo.ref) {
834862
return [];
835863
}
836864

837865
const { ref: branchName } = repositoryInfo;
838866

839-
const paramTree: API.RequestCreateTree[] = []
867+
const paramTree: API.RequestCreateTree[] = [];
840868

841869
for await (const action of actions) {
842870
// 先创建 blob 对象
843-
const blob = await this.rest.createBlob(repo, { content: action.content })
871+
const blob = await this.rest.createBlob(repo, { content: action.content });
844872

845873
// 然后将 sha 传递给 tree 数据源
846874
paramTree.push({
847875
path: action.file_path,
848876
mode: '100644',
849877
type: 'blob',
850-
sha: action.action_type === FileActionType.delete ? null : blob.sha
851-
})
878+
sha: action.action_type === FileActionType.delete ? null : blob.sha,
879+
});
852880
}
853881

854882
// 创建树
@@ -858,23 +886,26 @@ export class GitHubAPIService implements ICodeAPIService {
858886
const latestCommit = await this.rest.getCommit(repo, branchName);
859887

860888
// 创建 commit
861-
const commitData = await this.requestByREST<API.ResponseCreateCommit>(`/repos/${this.getProjectPath(repo)}/git/commits`, {
862-
responseType: 'json',
863-
method: 'post',
864-
data: {
865-
message: commit_message,
866-
tree: treeData.sha,
867-
parents: [latestCommit]
889+
const commitData = await this.requestByREST<API.ResponseCreateCommit>(
890+
`/repos/${this.getProjectPath(repo)}/git/commits`,
891+
{
892+
responseType: 'json',
893+
method: 'post',
894+
data: {
895+
message: commit_message,
896+
tree: treeData.sha,
897+
parents: [latestCommit],
898+
},
868899
}
869-
});
900+
);
870901

871902
// 将其关联分支的引用,此时才成功 push
872-
const referenceData = await this.rest.updateReference(repo, branchName, commitData.sha)
903+
const referenceData = await this.rest.updateReference(repo, branchName, commitData.sha);
873904

874905
return [
875906
{
876-
commit_id: referenceData.object.sha
877-
}
907+
commit_id: referenceData.object.sha,
908+
},
878909
] as FileOperateResult[];
879910
}
880911
}

packages/common/src/types/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface IExtensionBasicMetadata {
3939
description?: string;
4040
repository?: any;
4141
activationEvents?: string[];
42-
kaitianContributes?: JSONType;
42+
sumiContributes?: JSONType;
4343
contributes?: JSONType;
4444
};
4545
defaultPkgNlsJSON?: JSONType;

packages/core/extensions/codeblitz.css-language-features-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
"onLanguage:scss",
1818
"onCommand:_css.applyCodeAction"
1919
],
20-
"kaitianContributes": {
20+
"sumiContributes": {
2121
"workerMain": "client/dist/browser/cssClientMain.js"
2222
},
2323
"contributes": {

packages/core/extensions/codeblitz.git-graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
"activationEvents": [
1919
"*"
2020
],
21-
"kaitianContributes": {
21+
"sumiContributes": {
2222
"workerMain": "./dist/extension.js"
2323
},
2424
"contributes": {

packages/core/extensions/codeblitz.gitlens.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ module.exports = {
77
"packageJSON": {
88
"name": "gitlens",
99
"publisher": "codeblitz",
10-
"version": "10.2.3-2",
10+
"version": "10.2.4",
1111
"description": "gitlens for alex",
1212
"icon": "images/gitlens-icon.png",
1313
"activationEvents": [
1414
"*"
1515
],
16-
"kaitianContributes": {
16+
"sumiContributes": {
1717
"workerMain": "dist/extension.js"
1818
},
1919
"contributes": {

packages/core/extensions/codeblitz.html-language-features-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
"onLanguage:html",
1616
"onLanguage:handlebars"
1717
],
18-
"kaitianContributes": {
18+
"sumiContributes": {
1919
"workerMain": "client/dist/browser/htmlClientMain.js"
2020
},
2121
"contributes": {

packages/core/extensions/codeblitz.image-preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
"onCommand:imagePreview.zoomIn",
1717
"onCommand:imagePreview.zoomOut"
1818
],
19-
"kaitianContributes": {
19+
"sumiContributes": {
2020
"workerMain": "./dist/browser/extension.js"
2121
},
2222
"contributes": {

0 commit comments

Comments
 (0)