Skip to content

Commit 6b419ae

Browse files
chore: reuse TDesign ci workflow (#104)
Co-authored-by: 阿菜 Cai <jimmyrss1102@gmail.com>
1 parent 656568a commit 6b419ae

16 files changed

Lines changed: 123 additions & 51 deletions

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
// 'no-console': 'error'
1111
'@typescript-eslint/no-explicit-any': 'off',
1212
'@typescript-eslint/explicit-module-boundary-types': 'off',
13-
'@typescript-eslint/ban-ts-comment': 'off'
13+
'@typescript-eslint/ban-ts-comment': 'off',
14+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
1415
}
1516
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: main-site-publish
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v6
13+
14+
- uses: pnpm/action-setup@v4
15+
16+
- uses: actions/setup-node@v6
17+
with:
18+
node-version-file: .node-version
19+
20+
- run: pnpm install
21+
22+
- run: pnpm run site:preview
23+
24+
- run: sleep 3s
25+
26+
- uses: TDesignOteam/workflows/actions/setup-surge@main
27+
with:
28+
project: _site
29+
domain: tdesign-starter-cli.surge.sh
30+
token: ${{ secrets.TDESIGN_SURGE_TOKEN }}

.github/workflows/pkg-pr-new.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: pkg-pr-new
2+
on:
3+
push:
4+
branches: [develop]
5+
pull_request:
6+
branches: [develop]
7+
8+
jobs:
9+
build:
10+
if: ${{ github.repository == 'Tencent/tdesign-starter-cli' && !startsWith(github.head_ref, 'release/')}}
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v6
15+
16+
- uses: pnpm/action-setup@v4
17+
18+
- uses: actions/setup-node@v6
19+
with:
20+
node-version-file: .node-version
21+
22+
- run: pnpm install
23+
24+
- run: pnpm run build
25+
26+
27+
- run: pnpm dlx pkg-pr-new publish --bin --compact --packageManager=pnpm,npm
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 文件名建议统一为 preview-publish
2+
# 应用 preview.yml 的 demo
3+
name: PREVIEW_PUBLISH
4+
5+
on:
6+
workflow_run:
7+
workflows: ["MAIN_PULL_REQUEST"]
8+
types:
9+
- completed
10+
11+
jobs:
12+
call-preview:
13+
uses: TDesignOteam/workflows/.github/workflows/reusable-pr-preview.yml@main
14+
secrets:
15+
TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }}

.github/workflows/preview.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/pull-request.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 文件名建议统一为 pull-request.yml
2+
# 应用 test-build.yml 的 demo
3+
4+
name: MAIN_PULL_REQUEST
5+
6+
on:
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
call-test-build:
12+
uses: TDesignOteam/workflows/.github/workflows/reusable-unit-test.yml@main
13+
with:
14+
package-manager: pnpm
15+
node-version-file: .node-version

.github/workflows/tag-push.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ on: create
77

88
jobs:
99
call-publish:
10-
uses: Tencent/tdesign/.github/workflows/publish.yml@main
10+
if: github.event.ref_type == 'tag'
11+
uses: TDesignOteam/workflows/.github/workflows/reusable-publish-npm.yml@main
1112
secrets:
1213
TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }}
13-
TDESIGN_NPM_TOKEN: ${{ secrets.TDESIGN_NPM_TOKEN }}
14-
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
14+
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
15+
with:
16+
package-manager: pnpm
17+
node-version-file: .node-version
18+
permissions:
19+
contents: read
20+
id-token: write

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "tdesign-starter-cli",
33
"version": "0.5.3",
44
"description": "CLI tool for TDesign Starter project",
5+
"packageManager": "pnpm@10.30.3",
56
"type": "module",
67
"main": "./src/main.ts",
78
"lib": "./bin/index.js",
@@ -11,13 +12,13 @@
1112
"typings": "./src/types/index.d.ts",
1213
"scripts": {
1314
"watch": "rollup -w -c",
14-
"test": "npm run dev",
1515
"dev": "node ./bin/index.js",
1616
"prebuild": "rimraf bin/",
1717
"build": "rollup -c ",
1818
"lint": "eslint 'src/**/*.{js,ts}'",
1919
"site": "echo 'no need to build site'",
20-
"site:preview": "echo 'no need to run site preview'"
20+
"site:preview": "npm run build && tsx scripts/deploy.ts",
21+
"test": "echo \"No tests yet\" && exit 0"
2122
},
2223
"repository": {
2324
"type": "git",
@@ -46,7 +47,8 @@
4647
"eslint": "^8.56.0",
4748
"prettier": "^3.2.5",
4849
"rollup": "^4.29.1",
49-
"rollup-plugin-copy": "3.5.0"
50+
"rollup-plugin-copy": "3.5.0",
51+
"tsx": "^4.21.0"
5052
},
5153
"dependencies": {
5254
"@babel/plugin-transform-typescript": "^7.24.4",

scripts/deploy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const configFilesReg = async (configReg: RegExp, reg: RegExp, getNewConfigFile:
103103
// webpack-react 使用 build 目录
104104
const outputDir = template === 'template-webpack-react' ? 'build' : 'dist';
105105
const distFilePath = path.join(cwd, template, outputDir);
106-
const newDistFilePath = path.join(cwd, 'dist', template);
106+
const newDistFilePath = path.join(cwd, '_site', template);
107107
console.log(`准备拷贝 ${outputDir}: ${distFilePath} -> ${newDistFilePath}`);
108108

109109
if (!fs.existsSync(distFilePath)) {
@@ -147,7 +147,7 @@ const TEMPLATES: TemplateConfig[] = [
147147
const preview = async () => {
148148
try {
149149
// 创建 dist 目录
150-
mkdirSync('dist', { recursive: true });
150+
mkdirSync('_site', { recursive: true });
151151

152152
await initTemplates(TEMPLATES);
153153

0 commit comments

Comments
 (0)