Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

<!-- 请尽量按照下面几个方面给出解决bug必须得信息 -->

**描述bug**
清晰准确的描述bug

**如何复现**
给出详细的复现步骤
1、第一步 xxx
2、 第二步 xxx

**错误截图**
如果有可以将截图带上

**最小复现仓库或者地址**
重要!!!,请尽量给出复现仓库,这样能极大加快bug解决速度
16 changes: 16 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
感谢您贡献代码,共建指引详见: https://github.com/Tencent/wujie/blob/master/CONTRIBUTING.md

##### Checklist

<!-- 如已完成将 [ ] 改成 [x],可以删除不涉及的条目 -->

- [ ] 提交符合commit规范
- [ ] 文档更改
- [ ] 测试用例添加
- [ ] `npm run test`通过

##### 详细描述

- 特性
- 关联issue
112 changes: 112 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: npm publish

on:
push:
tags:
- v*
workflow_dispatch:
inputs:
ref:
description: "Tag or branch to publish, for example v2.0.0"
required: true
default: "master"

permissions:
contents: write
id-token: write

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}

- uses: pnpm/action-setup@v4
with:
version: 10.33.0

- uses: actions/setup-node@v4
with:
node-version: "24.x"
check-latest: true
cache: "pnpm"

- name: Setup npm for trusted publishing
run: |
npm install -g npm@11
npm --version

- name: install
run: pnpm i --filter "wujie-project" --filter "./packages/**" --frozen-lockfile

- name: publish to npm
run: |
./node_modules/.bin/lerna run prepack

node <<'NODE'
const fs = require("fs");
const path = require("path");

const packages = [
"packages/wujie-core",
"packages/wujie-react",
"packages/wujie-vue2",
"packages/wujie-vue3",
];

for (const dir of packages) {
const file = path.join(dir, "package.json");
const pkg = JSON.parse(fs.readFileSync(file, "utf8"));
let changed = false;

for (const field of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
const deps = pkg[field];
if (!deps) continue;

for (const [name, specifier] of Object.entries(deps)) {
if (typeof specifier === "string" && specifier.startsWith("workspace:")) {
deps[name] = specifier.replace(/^workspace:/, "");
changed = true;
}
}
}

if (changed) {
fs.writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
}
}
NODE

publish_package() {
package_dir="$1"
package_name="$(node -p "require('./${package_dir}/package.json').name")"
package_version="$(node -p "require('./${package_dir}/package.json').version")"

if npm view "${package_name}@${package_version}" version --registry=https://registry.npmjs.org/ >/dev/null 2>&1; then
echo "${package_name}@${package_version} already exists, skipping."
else
npm publish "./${package_dir}" --ignore-scripts --access public --registry=https://registry.npmjs.org/
fi
}

publish_package packages/wujie-core
publish_package packages/wujie-react
publish_package packages/wujie-vue2
publish_package packages/wujie-vue3
env:
NPM_CONFIG_PROVENANCE: "true"

- name: create GitHub release
if: startsWith(github.event.inputs.ref || github.ref_name, 'v')
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
echo "Release $RELEASE_TAG already exists."
else
gh release create "$RELEASE_TAG" --title "$RELEASE_TAG" --generate-notes
fi
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.event.inputs.ref || github.ref_name }}
116 changes: 116 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: PR Tests

on:
pull_request:
branches:
- master
paths-ignore:
- "**/*.md"
- "docs/**"
- "notes/**"

# 同一 PR 连续推送时自动取消上一次未完成的运行,节省 runner 时间
concurrency:
group: pr-tests-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
unit:
name: Unit tests (jsdom)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "pnpm"

- name: Install dependencies
run: pnpm i --filter "wujie-project" --filter "./packages/**" --frozen-lockfile

- name: Run unit tests
working-directory: packages/wujie-core
run: pnpm run test:unit

- name: Job summary
if: always()
run: |
echo "## Unit tests" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if [ "${{ job.status }}" = "success" ]; then
echo ":white_check_mark: All unit tests passed." >> "$GITHUB_STEP_SUMMARY"
else
echo ":x: Unit tests failed - see job logs above." >> "$GITHUB_STEP_SUMMARY"
fi

integration:
name: Integration tests (puppeteer)
runs-on: ubuntu-latest
timeout-minutes: 40
needs: unit
steps:
- uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
cache: "pnpm"

# 提高 inotify watcher 上限,避免 8 个 webpack/vue/vite dev server 并行启动
# 时触发 ENOSPC(GitHub runner 默认上限对多 dev-server 场景偏紧)
- name: Raise inotify limits
run: |
sudo sysctl -w fs.inotify.max_user_watches=524288
sudo sysctl -w fs.inotify.max_user_instances=512

# 集成测试需要在 8 个 examples/* 下启动各自的 dev server
# (react-dev-utils/@vue/cli-service/@angular/cli/vite 等依赖都在 example 里),
# 所以安装范围必须覆盖 examples/**,不能沿用 publish 流水线只装 packages/** 的做法
- name: Install dependencies
run: pnpm i --filter "wujie-project" --filter "./packages/**" --filter "./examples/**" --frozen-lockfile

# pnpm 10 默认不执行依赖 lifecycle script,puppeteer 的 install.js 不会自动下载 Chromium;
# 根 package.json 已配置 onlyBuiltDependencies,此处再显式执行一次以兼容 CI 缓存恢复场景
- name: Install Puppeteer Chromium
working-directory: packages/wujie-core
run: pnpm run install-puppeteer-browser

# examples 通过 main/module 字段引用 wujie / wujie-react / wujie-vue2 / wujie-vue3
# 的 lib/esm 产物,这些目录由 prepack(build.sh)生成。CI 全新仓库没有产物,
# 直接启动 dev server 会让主应用拿到空模块 → 页面空白 → 后续 selector 全找不到
- name: Build framework packages
env:
NODE_OPTIONS: --openssl-legacy-provider
run: ./node_modules/.bin/lerna run prepack

- name: Run integration tests
working-directory: packages/wujie-core
env:
NODE_OPTIONS: --openssl-legacy-provider
PUPPETEER_LAUNCH_ARGS: "--no-sandbox --disable-setuid-sandbox"
run: pnpm run test:integration

- name: Job summary
if: always()
run: |
echo "## Integration tests" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
if [ "${{ job.status }}" = "success" ]; then
echo ":white_check_mark: All integration tests passed." >> "$GITHUB_STEP_SUMMARY"
else
echo ":x: Integration tests failed - see job logs above." >> "$GITHUB_STEP_SUMMARY"
fi
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DS_Store
node_modules
dist
site
lib
esm
.DS_Store
.vscode
yarn.lock
coverage
.history
.npmrc
.cursor
.codegraph
.worktree

# Log files
.pnpm-debug.log*
cache
.idea
8 changes: 8 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# npx --no-install commitlint --edit "$1"

npm run husky-commitlint


4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

./node_modules/.bin/lerna run --scope wujie lint
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
printWidth: 120,
};
Loading
Loading