更新版本号至0.0.18,优化构建脚本,更新@types/node依赖至25.2.1,并重构CNBCore类以提高可读性
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@kevisual/cnb",
|
"name": "@kevisual/cnb",
|
||||||
"version": "0.0.16",
|
"version": "0.0.18",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "bun run bun.config.ts"
|
"build": "bun bun.config.ts",
|
||||||
|
"flow":"ev npm patch && pnpm build && ev npm publish npm -p"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"files": [
|
"files": [
|
||||||
@@ -24,7 +25,7 @@
|
|||||||
"@kevisual/types": "^0.0.12",
|
"@kevisual/types": "^0.0.12",
|
||||||
"@opencode-ai/plugin": "^1.1.51",
|
"@opencode-ai/plugin": "^1.1.51",
|
||||||
"@types/bun": "^1.3.8",
|
"@types/bun": "^1.3.8",
|
||||||
"@types/node": "^25.2.0",
|
"@types/node": "^25.2.1",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"dayjs": "^1.11.19",
|
"dayjs": "^1.11.19",
|
||||||
"dotenv": "^17.2.3"
|
"dotenv": "^17.2.3"
|
||||||
|
|||||||
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@@ -55,8 +55,8 @@ importers:
|
|||||||
specifier: ^1.3.8
|
specifier: ^1.3.8
|
||||||
version: 1.3.8
|
version: 1.3.8
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^25.2.0
|
specifier: ^25.2.1
|
||||||
version: 25.2.0
|
version: 25.2.1
|
||||||
'@types/ws':
|
'@types/ws':
|
||||||
specifier: ^8.18.1
|
specifier: ^8.18.1
|
||||||
version: 8.18.1
|
version: 8.18.1
|
||||||
@@ -118,8 +118,8 @@ packages:
|
|||||||
'@types/bun@1.3.8':
|
'@types/bun@1.3.8':
|
||||||
resolution: {integrity: sha512-3LvWJ2q5GerAXYxO2mffLTqOzEu5qnhEAlh48Vnu8WQfnmSwbgagjGZV6BoHKJztENYEDn6QmVd949W4uESRJA==}
|
resolution: {integrity: sha512-3LvWJ2q5GerAXYxO2mffLTqOzEu5qnhEAlh48Vnu8WQfnmSwbgagjGZV6BoHKJztENYEDn6QmVd949W4uESRJA==}
|
||||||
|
|
||||||
'@types/node@25.2.0':
|
'@types/node@25.2.1':
|
||||||
resolution: {integrity: sha512-DZ8VwRFUNzuqJ5khrvwMXHmvPe+zGayJhr2CDNiKB1WBE1ST8Djl00D0IC4vvNmHMdj6DlbYRIaFE7WHjlDl5w==}
|
resolution: {integrity: sha512-CPrnr8voK8vC6eEtyRzvMpgp3VyVRhgclonE7qYi6P9sXwYb59ucfrnmFBTaP0yUi8Gk4yZg/LlTJULGxvTNsg==}
|
||||||
|
|
||||||
'@types/ws@8.18.1':
|
'@types/ws@8.18.1':
|
||||||
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
|
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
|
||||||
@@ -328,13 +328,13 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bun-types: 1.3.8
|
bun-types: 1.3.8
|
||||||
|
|
||||||
'@types/node@25.2.0':
|
'@types/node@25.2.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 7.16.0
|
undici-types: 7.16.0
|
||||||
|
|
||||||
'@types/ws@8.18.1':
|
'@types/ws@8.18.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 25.2.0
|
'@types/node': 25.2.1
|
||||||
|
|
||||||
anymatch@3.1.3:
|
anymatch@3.1.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -343,7 +343,7 @@ snapshots:
|
|||||||
|
|
||||||
bun-types@1.3.8:
|
bun-types@1.3.8:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 25.2.0
|
'@types/node': 25.2.1
|
||||||
|
|
||||||
chokidar@5.0.0:
|
chokidar@5.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ export type RequestOptions = {
|
|||||||
useCookie?: boolean;
|
useCookie?: boolean;
|
||||||
useOrigin?: boolean;
|
useOrigin?: boolean;
|
||||||
};
|
};
|
||||||
|
const API_BASER_URL = 'https://api.cnb.cool'
|
||||||
|
const API_HACK_URL = 'https://cnb.cool'
|
||||||
export class CNBCore {
|
export class CNBCore {
|
||||||
baseURL = 'https://api.cnb.cool';
|
baseURL = API_BASER_URL;
|
||||||
hackURL = 'https://cnb.cool'
|
hackURL = API_HACK_URL;
|
||||||
public token: string;
|
public token: string;
|
||||||
public cookie?: string;
|
public cookie?: string;
|
||||||
constructor(options: CNBCoreOptions) {
|
constructor(options: CNBCoreOptions) {
|
||||||
@@ -37,8 +39,8 @@ export class CNBCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options?.cors?.baseUrl) {
|
if (options?.cors?.baseUrl) {
|
||||||
this.baseURL = options.cors.baseUrl + '/' + this.baseURL;
|
this.baseURL = options.cors.baseUrl + '/' + API_BASER_URL.replace('https://', '');
|
||||||
this.hackURL = options.cors.baseUrl + '/' + this.hackURL;
|
this.hackURL = options.cors.baseUrl + '/' + API_HACK_URL.replace('https://', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +109,11 @@ export class CNBCore {
|
|||||||
if (url && url.startsWith('http')) {
|
if (url && url.startsWith('http')) {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
return new URL(url || '', this.baseURL).toString();
|
console.log('url', url, this.baseURL)
|
||||||
|
if (url.startsWith('/')) {
|
||||||
|
return this.baseURL + url;
|
||||||
|
}
|
||||||
|
return this.baseURL + '/' + url;
|
||||||
}
|
}
|
||||||
get<T = any>({ url, ...REST }: RequestOptions): Promise<T> {
|
get<T = any>({ url, ...REST }: RequestOptions): Promise<T> {
|
||||||
const fullUrl = this.makeUrl(url);
|
const fullUrl = this.makeUrl(url);
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ import { Issue } from "../src/issue/index.ts";
|
|||||||
|
|
||||||
import { token, showMore, cookie } from "./common.ts";
|
import { token, showMore, cookie } from "./common.ts";
|
||||||
// group: "kevisual",
|
// group: "kevisual",
|
||||||
const issue = new Issue({ token: token, cookie: cookie });
|
const issue = new Issue({
|
||||||
|
token: token, cookie: cookie,
|
||||||
|
cors: {
|
||||||
|
// baseUrl: 'http://localhost:8080'
|
||||||
|
// baseUrl: 'https://cors.kevisual.cn'
|
||||||
|
baseUrl: 'http://cors.kevisual.cn:11111'
|
||||||
|
}
|
||||||
|
});
|
||||||
// const res = await issue.createIssue("cnb", {
|
// const res = await issue.createIssue("cnb", {
|
||||||
// title: "测试通过 API 创建 Issue",
|
// title: "测试通过 API 创建 Issue",
|
||||||
// })
|
// })
|
||||||
@@ -16,13 +23,13 @@ const issue = new Issue({ token: token, cookie: cookie });
|
|||||||
// });
|
// });
|
||||||
// console.log(showMore(updateIssueRes));
|
// console.log(showMore(updateIssueRes));
|
||||||
|
|
||||||
const itemIssueRes = await issue.getItem("cnb", 1);
|
// const itemIssueRes = await issue.getItem("cnb", 1);
|
||||||
console.log(showMore(itemIssueRes));
|
// console.log(showMore(itemIssueRes));
|
||||||
|
|
||||||
const listIssueRes = await issue.getList("cnb", {
|
const listIssueRes = await issue.getList("kevisual/kevisual", {
|
||||||
state: "open",
|
state: "open",
|
||||||
});
|
});
|
||||||
console.log(showMore(listIssueRes));
|
console.log(showMore(listIssueRes));
|
||||||
|
|
||||||
const commentListRes = await issue.getCommentList("cnb", 1);
|
// const commentListRes = await issue.getCommentList("kevisual/kevisual", 1);
|
||||||
console.log(showMore(commentListRes));
|
// console.log(showMore(commentListRes));
|
||||||
Reference in New Issue
Block a user