Skip to content

Commit 5722953

Browse files
authored
Initial commit
0 parents  commit 5722953

31 files changed

+9475
-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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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@v4
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+
npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version
81+
git config --local user.email "[email protected]"
82+
git config --local user.name "GitHub Action"
83+
git add package.json
84+
git commit -m "chore: bump version to ${{ steps.get_version.outputs.version }}"
85+
git tag ${{ steps.get_version.outputs.tag_name }}
86+
git push origin HEAD:${{ github.ref_name }}
87+
git push origin ${{ steps.get_version.outputs.tag_name }}
88+
89+
- name: 生成变更日志
90+
id: changelog
91+
run: npx changelogithub
92+
continue-on-error: true
93+
env:
94+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
95+
96+
- name: 发布到 npm
97+
run: pnpm publish --no-git-checks
98+
env:
99+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100+
101+
- name: 创建 GitHub Release
102+
uses: actions/create-release@v1
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
with:
106+
tag_name: ${{ steps.get_version.outputs.tag_name }}
107+
release_name: Release ${{ steps.get_version.outputs.tag_name }}
108+
body_path: ${{ steps.changelog.outputs.changelog_file }}
109+
draft: false
110+
prerelease: false
111+
112+
- name: 通知发布成功
113+
run: |
114+
echo "🎉 发布成功!"
115+
echo "📦 版本: ${{ steps.get_version.outputs.version }}"
116+
echo "🏷️ 标签: ${{ steps.get_version.outputs.tag_name }}"
117+
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+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Winjs dev Contrib
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# winjs-plugin-example
2+
3+
Example plugin for WinJS.
4+
5+
<p>
6+
<a href="https://npmjs.com/package/winjs-plugin-example">
7+
<img src="https://img.shields.io/npm/v/winjs-plugin-example?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
8+
</a>
9+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
10+
<a href="https://npmcharts.com/compare/winjs-plugin-example?minimal=true"><img src="https://img.shields.io/npm/dm/winjs-plugin-example.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
11+
</p>
12+
13+
## Usage
14+
15+
Install:
16+
17+
```bash
18+
npm add winjs-plugin-example -D
19+
```
20+
21+
Add plugin to your `.winrc.ts`:
22+
23+
```ts
24+
// .winrc.ts
25+
export default {
26+
plugins: ['winjs-plugin-example'],
27+
// 开启配置
28+
example: {}
29+
};
30+
```
31+
32+
## Options
33+
34+
### foo
35+
36+
Some description.
37+
38+
- Type: `string`
39+
- Default: `undefined`
40+
- Example:
41+
42+
```js
43+
export default {
44+
plugins: ['winjs-plugin-example'],
45+
// 开启配置
46+
example: {
47+
foo: 'bar'
48+
}
49+
};
50+
```
51+
52+
## License
53+
54+
[MIT](./LICENSE).

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+
}

0 commit comments

Comments
 (0)