新增 TypeScript 配置文件,设置编译选项;更新依赖项并添加开发依赖
This commit is contained in:
@@ -12,15 +12,15 @@ export const app = useContextKey("app", () => {
|
||||
export const token = useKey("CNB_API_KEY") || useKey('CNB_TOKEN')
|
||||
|
||||
export const cnb = useContextKey("cnb", () => {
|
||||
return new CNB({ token });
|
||||
return new CNB({ token: token as string });
|
||||
});
|
||||
|
||||
export const gitea = useContextKey('gitea', () => {
|
||||
const GITEA_TOKEN = useKey("GITEA_TOKEN")
|
||||
const GITEA_URL = useKey("GITEA_URL")
|
||||
return new Gitea({
|
||||
token: GITEA_TOKEN,
|
||||
baseURL: GITEA_URL,
|
||||
token: GITEA_TOKEN as string,
|
||||
baseURL: GITEA_URL as string,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useRepoInfoEnv } from '@kevisual/cnb';
|
||||
import { app, cnb } from '../app';
|
||||
import { app, cnb } from '../app.ts';
|
||||
import dayjs from 'dayjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { app, gitea, rootPath, token } from '../app'
|
||||
import { Repo } from './cnb';
|
||||
import { app, gitea, rootPath, token } from '../app.ts'
|
||||
import { Repo } from './cnb.ts';
|
||||
import { execSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import fs from 'fs';
|
||||
@@ -17,17 +17,19 @@ app.route({
|
||||
let syncList: Repo[] = [];
|
||||
for (const item of list) {
|
||||
try {
|
||||
const [owner, repo] = item.path.split('/');
|
||||
const giteaRepo = await gitea.repo.getRepo(owner, repo);
|
||||
const parts = item.path.split('/');
|
||||
const org = parts.slice(0, -1).join('_');
|
||||
const repo = parts[parts.length - 1];
|
||||
const giteaRepo = await gitea.repo.getRepo(org, repo);
|
||||
const giteaUsername = 'oauth2';
|
||||
const giteaPassword = useKey('GITEA_TOKEN');
|
||||
const giteaHost = useKey('GITEA_HOST') || 'git.xiongxiao.me';
|
||||
item.giteaUrl = `https://${giteaUsername}:${giteaPassword}@${giteaHost}/${owner}/${repo}.git`;
|
||||
item.giteaUrl = `https://${giteaUsername}:${giteaPassword}@${giteaHost}/${org}/${repo}.git`;
|
||||
if (giteaRepo.code === 200) {
|
||||
// 已经存在了
|
||||
} else {
|
||||
await gitea.repo.createRepo({
|
||||
name: owner + '/' + repo,
|
||||
name: org + '/' + repo,
|
||||
description: item.description,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user