Skip to content

Commit c845265

Browse files
committed
fix(deps): make gitee sdk optional
1 parent 1e03331 commit c845265

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@
6060
"lib": "dist",
6161
"doc": "docs"
6262
},
63+
"peerDependencies": {
64+
"@gitee/typescript-sdk-v5": "^5.4.85"
65+
},
66+
"peerDependenciesMeta": {
67+
"@gitee/typescript-sdk-v5": {
68+
"optional": true
69+
}
70+
},
6371
"dependencies": {
6472
"@commander-js/extra-typings": "^12.1.0",
6573
"@inquirer/prompts": "^6.0.0",
@@ -76,6 +84,7 @@
7684
"hookable": "^5.5.3",
7785
"mime": "^4.0.4",
7886
"octokit": "^4.0.2",
87+
"ofetch": "^1.4.1",
7988
"replace-in-file": "^8.2.0",
8089
"std-env": "^3.7.0",
8190
"update-notifier": "^7.3.1",

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/releaser/gitee.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import fs from "node:fs";
2+
import { basename, join } from "node:path";
3+
import { env } from "node:process";
4+
import { OpenAPI, RepositoriesService } from "@gitee/typescript-sdk-v5";
5+
import { globbySync } from "globby";
6+
import { ofetch } from "ofetch";
17
import { ReleaseBase } from "./base.js";
28

39
export default class Gitee extends ReleaseBase {
@@ -12,4 +18,43 @@ export default class Gitee extends ReleaseBase {
1218
repo,
1319
};
1420
}
21+
22+
private get token() {
23+
if (!env.GITEE_TOKEN)
24+
throw new Error("No GITEE_TOKEN provided!");
25+
return env.GITEE_TOKEN;
26+
}
27+
28+
// private getParams(params: object) {
29+
// return {
30+
// access_token: this.token,
31+
// ...this.remote,
32+
// ...params,
33+
// };
34+
// }
35+
36+
_fetch = ofetch.create({ baseURL: "https://gitee.com/api/v5", params: {
37+
access_token: this.token,
38+
...this.remote,
39+
} });
40+
41+
/**
42+
* @see https://gitee.com/api/v5/swagger#/getV5ReposOwnerRepoReleasesTagsTag
43+
*/
44+
private async getReleaseByTag(tag: string): Promise<{
45+
body: string;
46+
created_at: string;
47+
id: number;
48+
name: string;
49+
prerelease: boolean;
50+
tag_name: string;
51+
target_commitish: string;
52+
}> {
53+
// return (await _fetch(`/repos/{owner}/{repo}/releases/tags/{tag}`, { params: this.getParams({ tag }) }));
54+
return (await this._fetch(`/repos/{owner}/{repo}/releases/tags/{tag}`, { params: { tag } }));
55+
}
56+
57+
private async createRelease(tag_name: string, name: string, body: string, prerelease: boolean = false) {
58+
//
59+
}
1560
}

0 commit comments

Comments
 (0)