Skip to content

Commit 4589744

Browse files
committed
Initial project setup with essential configuration files including .gitignore, package.json, and TypeScript settings. Added Playwright for testing, Biome for linting, and integrated workflows for CI/CD with GitHub Actions. Implemented basic project structure in the playground directory for React development.
1 parent d179b51 commit 4589744

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2828
-0
lines changed

.github/renovate.json5

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:base", "schedule:monthly", "group:allNonMajor"],
4+
"rangeStrategy": "bump",
5+
"packageRules": [{ "depTypeList": ["peerDependencies"], "enabled": false }]
6+
}

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Lint
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on pull request events but only for the main branch
6+
pull_request:
7+
branches: [main]
8+
push:
9+
branches: [main]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
lint:
19+
runs-on: ubuntu-latest
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install Pnpm
27+
run: npm i -g corepack@latest --force && corepack enable
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 22
33+
cache: "pnpm"
34+
35+
- name: Install Dependencies
36+
run: pnpm install
37+
38+
- name: Run Lint
39+
run: pnpm run lint

.github/workflows/release.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: '发布版本 (例如: 1.0.0)'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
packages: write
20+
id-token: write
21+
22+
steps:
23+
- name: 检出代码
24+
uses: actions/checkout@v5
25+
with:
26+
fetch-depth: 0
27+
28+
- name: 设置 Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 22
32+
registry-url: 'https://registry.npmjs.org'
33+
34+
- name: 安装 pnpm
35+
uses: pnpm/action-setup@v4
36+
with:
37+
version: 10
38+
39+
- name: 获取 pnpm store 目录
40+
shell: bash
41+
run: |
42+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
43+
44+
- name: 设置 pnpm 缓存
45+
uses: actions/cache@v4
46+
with:
47+
path: ${{ env.STORE_PATH }}
48+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
49+
restore-keys: |
50+
${{ runner.os }}-pnpm-store-
51+
52+
- name: 安装依赖
53+
run: |
54+
# 尝试使用 frozen lockfile,如果失败则更新 lockfile
55+
pnpm install --frozen-lockfile || {
56+
echo "⚠️ Lockfile 不匹配,正在更新..."
57+
pnpm install --no-frozen-lockfile
58+
}
59+
60+
- name: 格式检查
61+
run: pnpm run lint
62+
63+
- name: 构建项目
64+
run: pnpm run build
65+
66+
- name: 获取版本号
67+
id: get_version
68+
run: |
69+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
70+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
71+
echo "tag_name=v${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
72+
else
73+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
74+
echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
75+
fi
76+
77+
- name: 更新版本号 (手动触发时)
78+
if: github.event_name == 'workflow_dispatch'
79+
run: |
80+
# 检查 tag 是否已经存在
81+
if git show-ref --tags --verify --quiet "refs/tags/${{ steps.get_version.outputs.tag_name }}"; then
82+
echo "⚠️ Tag ${{ steps.get_version.outputs.tag_name }} 已存在,跳过创建"
83+
else
84+
npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version
85+
git config --local user.email "[email protected]"
86+
git config --local user.name "GitHub Action"
87+
git add package.json
88+
git commit -m "chore: bump version to ${{ steps.get_version.outputs.version }}"
89+
git tag ${{ steps.get_version.outputs.tag_name }}
90+
git push origin HEAD:${{ github.ref_name }}
91+
git push origin ${{ steps.get_version.outputs.tag_name }}
92+
fi
93+
94+
- name: 生成变更日志
95+
id: changelog
96+
run: npx changelogithub
97+
continue-on-error: true
98+
env:
99+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
100+
101+
- name: 发布到 npm
102+
run: |
103+
# 检查版本是否已经发布到 npm
104+
PACKAGE_NAME=$(node -p "require('./package.json').name")
105+
CURRENT_VERSION=$(node -p "require('./package.json').version")
106+
107+
# 尝试获取 npm 上的版本信息
108+
if npm view "${PACKAGE_NAME}@${CURRENT_VERSION}" version 2>/dev/null; then
109+
echo "⚠️ 版本 ${CURRENT_VERSION} 已存在于 npm,跳过发布"
110+
else
111+
echo "📦 发布版本 ${CURRENT_VERSION} 到 npm..."
112+
pnpm publish --no-git-checks
113+
fi
114+
env:
115+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
116+
117+
- name: Create GitHub Release
118+
uses: ncipollo/release-action@v1
119+
with:
120+
generateReleaseNotes: "true"
121+
allowUpdates: true
122+
skipIfReleaseExists: false
123+
omitBodyDuringUpdate: false
124+
125+
- name: 通知发布成功
126+
run: |
127+
echo "🎉 发布成功!"
128+
echo "📦 版本: ${{ steps.get_version.outputs.version }}"
129+
echo "🏷️ 标签: ${{ steps.get_version.outputs.tag_name }}"
130+
echo "📝 npm: https://www.npmjs.com/package/winjs-plugin-template"

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on pull request events but only for the main branch
6+
pull_request:
7+
branches: [main]
8+
push:
9+
branches: [main]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
test:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, windows-latest]
23+
24+
# Steps represent a sequence of tasks that will be executed as part of the job
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install Pnpm
30+
run: npm i -g corepack@latest --force && corepack enable
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 22
36+
cache: "pnpm"
37+
38+
- name: Install Dependencies
39+
run: pnpm install && npx playwright install chromium
40+
41+
- name: Run Test
42+
run: pnpm run test

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Local
2+
.DS_Store
3+
*.local
4+
*.log*
5+
6+
# Dist
7+
node_modules
8+
dist/
9+
test-results
10+
11+
# IDE
12+
.vscode/*
13+
!.vscode/settings.json
14+
!.vscode/extensions.json
15+
.idea
16+
17+
# playground
18+
/playground/src/.win
19+
/playground/src/.win-production
20+
/playground/src/.win-test
21+
/playground/components.d.ts
22+
/playground/auto-imports.d.ts
23+
/playground/.eslintrc-auto-import.json

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["biomejs.biome"]
3+
}

.vscode/settings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"search.useIgnoreFiles": true,
3+
"[json]": {
4+
"editor.defaultFormatter": "biomejs.biome"
5+
},
6+
"[typescript]": {
7+
"editor.defaultFormatter": "biomejs.biome"
8+
},
9+
"[javascript]": {
10+
"editor.defaultFormatter": "biomejs.biome"
11+
},
12+
"[javascriptreact]": {
13+
"editor.defaultFormatter": "biomejs.biome"
14+
},
15+
"[css]": {
16+
"editor.defaultFormatter": "biomejs.biome"
17+
}
18+
}

biome.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"assist": {
4+
"actions": {
5+
"source": {
6+
"organizeImports": "on"
7+
}
8+
}
9+
},
10+
"files": {
11+
"includes": ["src/**"]
12+
},
13+
"vcs": {
14+
"enabled": true,
15+
"defaultBranch": "main",
16+
"clientKind": "git",
17+
"useIgnoreFile": true
18+
},
19+
"formatter": {
20+
"indentStyle": "space"
21+
},
22+
"javascript": {
23+
"formatter": {
24+
"quoteStyle": "single"
25+
}
26+
},
27+
"css": {
28+
"formatter": {
29+
"enabled": true
30+
}
31+
},
32+
"linter": {
33+
"enabled": true,
34+
"rules": {
35+
"recommended": true
36+
}
37+
}
38+
}

package.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "winjs-plugin-template",
3+
"keywords": [
4+
"winjs",
5+
"plugin",
6+
"template",
7+
"winner-fed",
8+
"winjs-dev",
9+
"rslib",
10+
"rsbuild",
11+
"typescript",
12+
"biome"
13+
],
14+
"version": "0.0.0",
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/winjs-dev/winjs-plugin-template.git"
18+
},
19+
"license": "MIT",
20+
"type": "module",
21+
"exports": {
22+
".": {
23+
"types": "./dist/index.d.ts",
24+
"import": "./dist/index.js",
25+
"require": "./dist/index.cjs"
26+
}
27+
},
28+
"main": "./dist/index.cjs",
29+
"module": "./dist/index.js",
30+
"types": "./dist/index.d.ts",
31+
"files": [
32+
"dist"
33+
],
34+
"scripts": {
35+
"build": "rslib build",
36+
"dev": "rslib build --watch",
37+
"lint": "biome check .",
38+
"lint:write": "biome check . --write",
39+
"prepare": "simple-git-hooks && npm run build",
40+
"test": "playwright test",
41+
"bump": "bumpp"
42+
},
43+
"simple-git-hooks": {
44+
"pre-commit": "npm run lint:write"
45+
},
46+
"devDependencies": {
47+
"@biomejs/biome": "^2.1.1",
48+
"@playwright/test": "^1.53.2",
49+
"@rsbuild/core": "^1.4.2",
50+
"@rslib/core": "^0.10.4",
51+
"@types/node": "^22.15.34",
52+
"@winner-fed/winjs": "*",
53+
"bumpp": "10.2.3",
54+
"simple-git-hooks": "^2.13.0",
55+
"typescript": "^5.8.3"
56+
},
57+
"peerDevDependencies": {
58+
"@winner-fed/winjs": "*"
59+
},
60+
"peerDependencies": {
61+
"@winner-fed/utils": "*"
62+
},
63+
"peerDependenciesMeta": {
64+
"@rsbuild/core": {
65+
"optional": true
66+
},
67+
"@winner-fed/utils": {
68+
"optional": true
69+
}
70+
},
71+
"publishConfig": {
72+
"access": "public",
73+
"registry": "https://registry.npmjs.org/"
74+
}
75+
}

0 commit comments

Comments
 (0)