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

chore(release): release v2.3.4 #230

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "2.3.3"
"version": "2.3.4"
}
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-cli",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-cli",
"main": "lib/commander.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/code-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-code-api",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-code-api",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
97 changes: 87 additions & 10 deletions packages/code-api/src/atomgit/atomgit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EntryParam,
FileAction,
FileActionHeader,
FileActionResult,
GetEntryInfoParam,
GitlensBlame,
ICodeAPIService,
Expand Down Expand Up @@ -135,7 +136,7 @@ export class AtomGitAPIService implements ICodeAPIService {
});
}

protected async request<T>(path: string, options?: RequestOptions): Promise<T> {
protected async request<T>(path: string, options?: RequestOptions, responseOptions?: API.RequestResponseOptions): Promise<T> {
try {
const { headers, ...rest } = options || {};
const privateToken = this.PRIVATE_TOKEN;
Expand All @@ -162,6 +163,10 @@ export class AtomGitAPIService implements ICodeAPIService {
} else if (status === 404) {
messageKey = 'error.resource-not-found';
}
if (responseOptions?.errorOption === false) {
console.log(err);
return undefined as any;
}
this.showErrorMessage(messageKey, status);
throw err;
}
Expand Down Expand Up @@ -221,8 +226,29 @@ export class AtomGitAPIService implements ICodeAPIService {

return Buffer.from(content);
}
getBlobByCommitPath(_repo: IRepositoryModel, _commit: string, _path: string, _options?: any): Promise<Uint8Array> {
throw new Error('Method not implemented.');
async getBlobByCommitPath(repo: IRepositoryModel, commit: string, path: string, options?: API.RequestResponseOptions): Promise<Uint8Array> {
const res = await this.request<API.ResponseInfoAndBlobs>(
`/repos/${this.getProjectPath(repo)}/contents/file`,
{
params: {
path: path,
ref: commit
},
},
options
);

const { content, encoding, type } = res;

if (type !== 'file') {
throw new Error(`${path} is not a file.`);
}

if (encoding === 'base64') {
return Buffer.from(decodeURIComponent(escape(atob(content))));
}

return Buffer.from(content);
}
async getBranches(repo: IRepositoryModel): Promise<BranchOrTag[]> {
if (!this.PRIVATE_TOKEN) {
Expand Down Expand Up @@ -322,17 +348,68 @@ export class AtomGitAPIService implements ICodeAPIService {
getCommitCompare(_repo: IRepositoryModel, _from: string, _to: string): Promise<CommitFileChange[]> {
throw new Error('Method not implemented.');
}
async getFiles(_repo: IRepositoryModel): Promise<string[]> {
return [];
async getFiles(repo: IRepositoryModel): Promise<string[]> {
const fileList = await this.request<API.ResponseFileNames[]>(
`/repos/${this.getProjectPath(repo)}/trees/${repo.commit}`,
{
params: {
recursive: 'true',
},
},
);
return (fileList || []).filter(f => f.type === 'blob').map((f) => f.path);
}
bulkChangeFiles(_repo: IRepositoryModel, _actions: FileAction[], _header: FileActionHeader): Promise<any> {
throw new Error('Method not implemented.');
async bulkChangeFiles(repo: IRepositoryModel, actions: FileAction[], header: FileActionHeader): Promise<FileActionResult[]> {
const res = await this.request<API.ResponseCommitInfo>(
`/repos/${this.getProjectPath(repo)}/commits/create`,
{
data: {
actions: actions.map((action) => ({
action: action.action_type.toLocaleLowerCase(),
file_path: action.file_path,
content: action.content,
previous_path: action.file_path,
})),
branch: header.branch,
commit_message: header.commit_message,
},
method: 'post',
},
);
const resCommit = {
branch_created: false,
branch: header.branch,
commit_id: res.id,
file_name: '',
...res,
};
// 没有提交ID 说明提交失败
if (res.id) {
return [resCommit] as FileActionResult[];
}
return [];
}
createBranch(_repo: IRepositoryModel, _newBranch: string, _ref: string): Promise<Branch> {
throw new Error('Method not implemented.');
async createBranch(repo: IRepositoryModel, newBranch: string, ref: string): Promise<Branch> {
const res = await this.request<API.ResponseBranch>(`/repos/${this.getProjectPath(repo)}/git/refs`, {
method: 'post',
data: {
sha: ref,
ref: newBranch,
},
});

const resBranch: Branch = {
commit: {
id: res.object?.sha,
},
name: res.ref,
ref: res.ref,
}

return resBranch;
}
getUser(_repo: IRepositoryModel): Promise<any> {
throw new Error('Method not implemented.');
return {} as any;
}

public async getProject(repo: IRepositoryModel): Promise<Project> {
Expand Down
45 changes: 45 additions & 0 deletions packages/code-api/src/atomgit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,53 @@ export namespace API {
};
}

export interface ResponseCommitInfo {
author_email: string;
author_name: string;
authored_date: string;
committed_date: string;
committer_email: string;
committer_name: string;
created_at: string;
id: string;
message: string;
parent_ids: string[];
short_id: string;
title: string;
}

export interface ResponseRepoInfo {
name: string;
default_branch: string;
}

export interface ResponseBranch {
object: {
sha: string;
type: string;
}
ref: string;
}

export interface ResponseInfoAndBlobs {
content: string;
download_url: string;
encoding: string;
name: string;
path: string;
sha: string;
size: number;
type: 'file' | string;
}

export interface ResponseFileNames {
path: string;
sha: string;
mode: string;
type: 'tree' | 'blob' | string;
}

export interface RequestResponseOptions {
errorOption?: boolean;
}
}
2 changes: 1 addition & 1 deletion packages/code-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-code-service",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-code-service",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-common",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-common",
"main": "lib/index.js",
"typing": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-core",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-core",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-i18n",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-i18n",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-plugin",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-plugin",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/registry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-registry",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-registry",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/startup/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-startup",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-startup",
"main": "lib/index.js",
"typing": "types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/sumi-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-sumi-core",
"version": "2.3.3",
"version": "2.3.4",
"description": "core",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codeblitzjs/ide-toolkit",
"version": "2.3.3",
"version": "2.3.4",
"description": "@codeblitzjs/ide-toolkit",
"main": "index.js",
"files": [
Expand Down
Loading