Skip to content

Commit

Permalink
fix(deps): make gitee sdk optional
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Oct 17, 2024
1 parent e23f292 commit 2128309
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
"lib": "dist",
"doc": "docs"
},
"peerDependencies": {
"@gitee/typescript-sdk-v5": "^5.4.85"
},
"peerDependenciesMeta": {
"@gitee/typescript-sdk-v5": {
"optional": true
}
},
"dependencies": {
"@commander-js/extra-typings": "^12.1.0",
"@inquirer/prompts": "^6.0.0",
Expand All @@ -76,6 +84,7 @@
"hookable": "^5.5.3",
"mime": "^4.0.4",
"octokit": "^4.0.2",
"ofetch": "^1.4.1",
"replace-in-file": "^8.2.0",
"std-env": "^3.7.0",
"update-notifier": "^7.3.1",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions src/core/releaser/gitee.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import fs from "node:fs";
import { basename, join } from "node:path";
import { env } from "node:process";
import { OpenAPI, RepositoriesService } from "@gitee/typescript-sdk-v5";
import { globbySync } from "globby";
import { ofetch } from "ofetch";
import { ReleaseBase } from "./base.js";

export default class Gitee extends ReleaseBase {
Expand All @@ -12,4 +18,43 @@ export default class Gitee extends ReleaseBase {
repo,
};
}

private get token() {
if (!env.GITEE_TOKEN)
throw new Error("No GITEE_TOKEN provided!");
return env.GITEE_TOKEN;
}

// private getParams(params: object) {
// return {
// access_token: this.token,
// ...this.remote,
// ...params,
// };
// }

_fetch = ofetch.create({ baseURL: "https://gitee.com/api/v5", params: {
access_token: this.token,
...this.remote,
} });

/**
* @see https://gitee.com/api/v5/swagger#/getV5ReposOwnerRepoReleasesTagsTag
*/
private async getReleaseByTag(tag: string): Promise<{
body: string;
created_at: string;
id: number;
name: string;
prerelease: boolean;
tag_name: string;
target_commitish: string;
}> {
// return (await _fetch(`/repos/{owner}/{repo}/releases/tags/{tag}`, { params: this.getParams({ tag }) }));
return (await this._fetch(`/repos/{owner}/{repo}/releases/tags/{tag}`, { params: { tag } }));
}

private async createRelease(tag_name: string, name: string, body: string, prerelease: boolean = false) {
//
}
}

0 comments on commit 2128309

Please sign in to comment.