mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-26 21:20:31 +00:00
简化
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- name: Create release
|
- name: Create release
|
||||||
run: |
|
run: |
|
||||||
export TZ=Asia/Shanghai
|
export TZ=Asia/Shanghai
|
||||||
TAG="v$(deno -A --allow-scripts version.ts).$(date +%y%m%d%H%M)"
|
TAG="v$(./build.ts).$(date +%y%m%d%H%M)"
|
||||||
gh release create "$TAG" dist/* --notes-file .github/release.md --draft -t $TAG
|
gh release create "$TAG" dist/* --notes-file .github/release.md --draft -t $TAG
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
4. 在设置中查看主题
|
4. 在设置中查看主题
|
||||||
|
|
||||||
`gitea/conf/app.ini` 例:
|
`gitea/conf/app.ini` 例:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[ui]
|
[ui]
|
||||||
THEMES = gitea-dark, github
|
THEMES = gitea-dark, github
|
||||||
@@ -47,18 +48,11 @@ THEMES = gitea-dark, github
|
|||||||
```bash
|
```bash
|
||||||
git clone https://github.com/lutinglt/gitea-github-theme.git
|
git clone https://github.com/lutinglt/gitea-github-theme.git
|
||||||
cd gitea-github-theme
|
cd gitea-github-theme
|
||||||
deno install --allow-scripts
|
|
||||||
deno run build
|
deno run build
|
||||||
```
|
```
|
||||||
|
|
||||||
查看用于 Gitea 的主题文件: `./dist/theme-github.css`
|
查看用于 Gitea 的主题文件: `./dist/theme-github.css`
|
||||||
|
|
||||||
在开发过程中实时构建主题文件
|
|
||||||
|
|
||||||
```bash
|
|
||||||
deno run watch
|
|
||||||
```
|
|
||||||
|
|
||||||
## 贡献
|
## 贡献
|
||||||
|
|
||||||
欢迎提交 Issue 或 Pull Request
|
欢迎提交 Issue 或 Pull Request
|
||||||
43
build.ts
Executable file
43
build.ts
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env -S deno run -A --allow-scripts
|
||||||
|
|
||||||
|
import * as sass from "npm:sass";
|
||||||
|
import * as yaml from "npm:js-yaml";
|
||||||
|
|
||||||
|
interface Asset {
|
||||||
|
name: string;
|
||||||
|
css: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Theme {
|
||||||
|
version: string;
|
||||||
|
theme: string;
|
||||||
|
description: string;
|
||||||
|
assets: Asset[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Gitea {
|
||||||
|
gitea: Theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildTheme(themePath: string) {
|
||||||
|
try {
|
||||||
|
const inputFile = "sass/theme-github.scss";
|
||||||
|
const outputFile = "dist/theme-github.css";
|
||||||
|
|
||||||
|
const result = await sass.compileAsync(inputFile, { sourceMap: false, style: "compressed" });
|
||||||
|
await Deno.writeTextFile(outputFile, result.css);
|
||||||
|
|
||||||
|
const fileContent = await Deno.readTextFile(themePath);
|
||||||
|
const data: Gitea = yaml.load(fileContent);
|
||||||
|
console.log(data.gitea.version);
|
||||||
|
} catch (error) {
|
||||||
|
let e = error;
|
||||||
|
if (error instanceof Error) {
|
||||||
|
e = error.message;
|
||||||
|
}
|
||||||
|
console.error("Build failed:", e);
|
||||||
|
Deno.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTheme("theme.yml");
|
||||||
12
deno.json
12
deno.json
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"nodeModulesDir": "auto",
|
"nodeModulesDir": "auto",
|
||||||
"tasks": {
|
"fmt": {
|
||||||
"export": "sass src/theme-github.scss:dist/theme-github.css --no-source-map",
|
"options": {
|
||||||
"build": "deno run export --style=compressed",
|
"lineWidth": 120
|
||||||
"watch": "deno run export --watch"
|
}
|
||||||
},
|
},
|
||||||
"imports": {
|
"tasks": {
|
||||||
"sass": "npm:sass@^1.84.0"
|
"build": "./build.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
version.ts
37
version.ts
@@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env -S deno run -A
|
|
||||||
|
|
||||||
import * as yaml from "npm:js-yaml";
|
|
||||||
|
|
||||||
interface Asset {
|
|
||||||
name: string;
|
|
||||||
css: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Theme {
|
|
||||||
version: string;
|
|
||||||
theme: string;
|
|
||||||
description: string;
|
|
||||||
assets: Asset[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Gitea {
|
|
||||||
gitea: Theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function readYamlFile(filePath: string) {
|
|
||||||
try {
|
|
||||||
const fileContent = await Deno.readTextFile(filePath);
|
|
||||||
const data: Gitea = yaml.load(fileContent);
|
|
||||||
console.log(data.gitea.version);
|
|
||||||
} catch (error) {
|
|
||||||
let e = error;
|
|
||||||
if (error instanceof Error) {
|
|
||||||
e = error.message;
|
|
||||||
}
|
|
||||||
console.error("Error reading or parsing YAML file:", e);
|
|
||||||
Deno.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用示例
|
|
||||||
readYamlFile("theme.yml");
|
|
||||||
Reference in New Issue
Block a user