nodejs->deno

This commit is contained in:
lutinglt
2025-02-13 01:13:32 +08:00
parent c0d181278f
commit 34f72da8b5
10 changed files with 61 additions and 75 deletions

16
.github/release.js vendored
View File

@@ -1,16 +0,0 @@
const fs = require('fs').promises;
const yaml = require('js-yaml');
async function parseYaml() {
try {
const fileContents = await fs.readFile('./theme.yml', 'utf8');
const data = yaml.load(fileContents);
console.log(data.gitea.version);
} catch (e) {
console.error('Error parsing YAML:', e.message);
process.exit(1);
}
}
parseYaml();

View File

@@ -11,15 +11,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-node@v4 - uses: denoland/setup-deno@v2
with: with:
node-version: 20 deno-version: v2.x
- name: NPM install
run: npm install
- name: Create release - name: Create release
run: | run: |
export TZ=Asia/Shanghai export TZ=Asia/Shanghai
TAG="v$(node .github/release.js)-$(date +%y%m%d%H%M)" TAG="v$(deno -A version.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 }}

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
node_modules node_modules
package-lock.json deno.lock

View File

@@ -1,3 +0,0 @@
dist/
node_modules/
package-lock.json

View File

@@ -1,16 +0,0 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}

View File

@@ -42,13 +42,13 @@ THEMES = gitea-dark, github
## 构建 ## 构建
需要 nodejs 和 npm 需要 deno
```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
npm install deno install --allow-scripts
npm run build deno run build
``` ```
查看用于 Gitea 的主题文件: `./dist/theme-github.css` 查看用于 Gitea 的主题文件: `./dist/theme-github.css`
@@ -56,7 +56,7 @@ npm run build
在开发过程中实时构建主题文件 在开发过程中实时构建主题文件
```bash ```bash
npm run watch deno run watch
``` ```
## 贡献 ## 贡献

11
deno.json Normal file
View File

@@ -0,0 +1,11 @@
{
"nodeModulesDir": "auto",
"tasks": {
"export": "sass src/theme-github.scss:dist/theme-github.css --no-source-map",
"build": "deno run export --style=compressed",
"watch": "deno run export --watch"
},
"imports": {
"sass": "npm:sass@^1.84.0"
}
}

View File

@@ -1,25 +0,0 @@
{
"name": "gitea-github-theme",
"version": "1.0.0",
"description": "尽量保持与 GitHub Dark 相同样式的 Gitea 主题",
"scripts": {
"export": "sass src/theme-github.scss:dist/theme-github.css --no-source-map",
"build": "npm run export -- --style=compressed",
"watch": "npm run export -- --watch"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lutinglt/gitea-github-theme.git"
},
"keywords": [],
"author": "",
"type": "commonjs",
"bugs": {
"url": "https://github.com/lutinglt/gitea-github-theme/issues"
},
"homepage": "https://github.com/lutinglt/gitea-github-theme#readme",
"devDependencies": {
"js-yaml": "^4.1.0",
"sass": "^1.83.0"
}
}

View File

@@ -6,7 +6,7 @@
min-height: calc(-104px + 100vh); min-height: calc(-104px + 100vh);
&:before { &:before {
content: 'Actions'; content: "Actions";
display: block; display: block;
font-size: 20px; font-size: 20px;
font-weight: 600; font-weight: 600;
@@ -17,7 +17,7 @@
.twelve.wide { .twelve.wide {
&:before { &:before {
content: 'Workflow Runs'; content: "Workflow Runs";
display: block; display: block;
font-size: 20px; font-size: 20px;
margin-top: 6px; margin-top: 6px;
@@ -120,7 +120,7 @@
} }
.action-commit-summary { .action-commit-summary {
margin-left: 28+14px; margin-left: 28 + 14px;
} }
} }
} }
@@ -146,7 +146,7 @@
border-top: 1px solid #2f353d; border-top: 1px solid #2f353d;
&:before { &:before {
content: 'Jobs'; content: "Jobs";
color: #9198a1; color: #9198a1;
font-size: 12px; font-size: 12px;
font-weight: 600; font-weight: 600;
@@ -179,7 +179,7 @@
overflow: visible; overflow: visible;
background: #1f6feb; background: #1f6feb;
border-radius: 0.375rem; border-radius: 0.375rem;
content: ''; content: "";
height: 24px; height: 24px;
left: calc(0.5rem * -1); left: calc(0.5rem * -1);
position: absolute; position: absolute;

37
version.ts Executable file
View File

@@ -0,0 +1,37 @@
#!/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");