Compare commits

..

2 Commits
v4.6.4 ... next

Author SHA1 Message Date
chenjiahan
b45b0b7608 chore: update branches in GitHub actions 2022-09-10 21:57:09 +08:00
chenjiahan
c309ca2aaf docs: switch dev branch to v4 2022-09-10 21:53:49 +08:00
1086 changed files with 9466 additions and 62563 deletions

View File

@ -0,0 +1,5 @@
注意gitee 中为 vant 的镜像仓库,不进行 issue 处理。
请移步 GitHub issues 进行反馈:
https://github.com/vant-ui/vant/issues

View File

@ -1,4 +1,39 @@
# Vant Contributing Guide
# Contributing to Vant
- [English Version](../packages/vant/docs/markdown/contribution.en-US.md)
- [中文版](../packages/vant/docs/markdown/contribution.zh-CN.md)
The following is a set of guidelines for contributing to Vant. Please spend several minutes in reading these guidelines before you create an issue or pull request.
Anyway, these are just guidelines, not rules, use your best judgment and feel free to propose changes to this document in a pull request.
## Opening an Issue
If you think you have found a bug, or have a new feature idea, please start by making sure it hasn't already been reported or fixed. You can search through existing issues and PRs to see if someone has reported one similar to yours.
Next, create a new issue that briefly explains the problem, and provides a bit of background as to the circumstances that triggered it, and steps to reproduce it.
## Submitting a Pull Request
It's welcomed to pull request, And there are some tips about that:
- Before working on a large change, it is best to open an issue first to discuss it with the maintainers.
- When in doubt, keep your pull requests small. To give a PR the best chance of getting accepted, don't bundle more than one feature or bug fix per pull request. It's always best to create two smaller PRs than one big one.
- When adding new features or modifying existing, please attempt to include tests to confirm the new behavior.
- Rebase before creating a PR to keep commit history clear.
- Add some descriptions and refer relative issues for you PR.
## Getting started
You will need [Node.js >= 14](https://nodejs.org) and [pnpm](https://pnpm.io).
```bash
git clone git@github.com:vant-ui/vant.git
# Install dependencies
pnpm i
# Start development
pnpm dev
```

View File

@ -1,8 +1 @@
blank_issues_enabled: true
contact_links:
- name: Ask a question
url: https://github.com/youzan/vant/discussions
about: Ask a question about Vant
- name: 提问
url: https://github.com/youzan/vant/discussions
about: 询问 Vant 的用法问题

View File

@ -1,3 +1,30 @@
Before submitting a pull request, please read the [contributing guide](https://vant-contrib.gitee.io/vant/#/en-US/contribution).
### Before submitting a pull request, please make sure the following is done:
在提交 pull request 之前,请阅读 [贡献指南](https://vant-contrib.gitee.io/vant/#/zh-CN/contribution)。
1. Read the [contributing guide](https://github.com/vant-ui/vant/blob/dev/.github/CONTRIBUTING.md).
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes (`npm test`).
#### Title Format
type(ComponentName?)commit message
Example
- docs: fix typo in quickstart
- build: optimize build speed
- fix(Button): incorrect style
- feat(Button): add color prop
Allowed Types:
- fix
- feat
- docs
- perf
- test
- types
- build
- chore
- refactor
- breaking change

View File

@ -1,8 +0,0 @@
"change: feat":
- "/^(feat|perf|types|style)/"
"change: fix":
- "/^fix/"
"change: breaking":
- "/^breaking change/"
"change: docs":
- "/^docs/"

23
.github/release.yml vendored
View File

@ -1,23 +0,0 @@
# .github/release.yml
changelog:
exclude:
authors:
# Ignore the release PR created by github-actions
- github-actions
categories:
- title: Breaking Changes 🍭
labels:
- "change: breaking"
- title: New Features 🎉
labels:
- "change: feat"
- title: Bug Fixes 🐞
labels:
- "change: fix"
- title: Document 📖
labels:
- "change: docs"
- title: Other Changes
labels:
- "*"

View File

@ -13,10 +13,10 @@ name: "CodeQL"
on:
push:
branches: [ main ]
branches: [ dev ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [ dev ]
schedule:
- cron: '36 21 * * 2'

View File

@ -2,7 +2,7 @@ name: Deploy V4 Site
on:
push:
branches: [main]
branches: [dev]
paths:
- 'packages/vant/docs/**'
@ -15,14 +15,14 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
ref: 'main'
ref: 'next'
- name: Install pnpm
run: corepack enable
run: npm i pnpm@7 -g
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '16'
cache: 'pnpm'
- name: Install dependencies
@ -31,49 +31,10 @@ jobs:
- name: Build Site
run: npm run build:site
- name: Deploy for Gitee 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.0
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
folder: packages/vant/site-dist
clean: true
clean-exclude: |
1.x/*
1.x/**/*
next/*
next/**/*
v1/*
v1/**/*
v2/*
v2/**/*
v3/*
v3/**/*
v4/*
v4/**/*
vant-use/*
vant-use/**/*
- name: Deploy for GitHub 🚀
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
branch: main
folder: packages/vant/site-dist
token: ${{ secrets.VANT_UI_TOKEN }}
repository-name: vant-ui/vant-ui.github.io
target-folder: vant
clean: true
clean-exclude: |
1.x/*
1.x/**/*
next/*
next/**/*
v1/*
v1/**/*
v2/*
v2/**/*
v3/*
v3/**/*
v4/*
v4/**/*
vant-use/*
vant-use/**/*
target-folder: v4
clean: false

View File

@ -1,25 +0,0 @@
name: Issue Close Require
on:
schedule:
- cron: '0 0 * * *'
permissions:
contents: read
jobs:
issue-close-require:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: need reproduce
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issues'
labels: 'need reproduce'
inactive-day: 3
body: |
Since the issue was labeled with `need reproduce`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.
由于该 issue 被标记为需要复现,却 3 天未收到回应。现关闭 issue若有任何问题可评论回复。

View File

@ -1,69 +0,0 @@
name: Issue Labeled
on:
issues:
types: [labeled]
permissions:
contents: read
jobs:
reply-labeled:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: help wanted
if: github.event.label.name == '👏 PR welcome' || github.event.label.name == 'help wanted'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}. We totally like your proposal/feedback, welcome to [send us a Pull Request](https://help.github.com/en/articles/creating-a-pull-request) for it. Please send your Pull Request to `main` branch, fill the [Pull Request Template](https://github.com/vant-ui/vant/blob/main/.github/PULL_REQUEST_TEMPLATE.md) here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!
你好 @${{ github.event.issue.user.login }},我们完全同意你的提议/反馈,欢迎直接在此仓库 [创建一个 Pull Request](https://help.github.com/en/articles/creating-a-pull-request) 来解决这个问题。请将 Pull Request 发到 `main` 分支,务必填写 Pull Request 内的[预设模板](https://github.com/vant-ui/vant/blob/main/.github/PULL_REQUEST_TEMPLATE.md),提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review提前感谢和期待您的贡献。
- name: need reproduce
if: github.event.label.name == 'need reproduce'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}. Please provide an online reproduction demo by clicking this [link](https://codesandbox.io/s/vant-3-issue-template-8fuq5o) or a minimal GitHub repository. Issues marked with `need reproduce` will be closed if they have no activity within 3 days.
你好 @${{ github.event.issue.user.login }}, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。可以通过点击 [此处](https://codesandbox.io/s/vant-3-issue-template-8fuq5o) 创建或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。
- name: question
if: github.event.label.name == 'question'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment, close-issue'
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}, we use GitHub issues to trace bugs or discuss plans of Vant. So, please don't ask usage questions here. You can try to open a new discussion in [vant discussions](https://github.com/vant-ui/vant/discussions), select `Q&A` to ask questions.
你好 @${{ github.event.issue.user.login }}Vant Issue 板块是用于 bug 反馈与需求讨论的地方。请勿在这里询问如何使用等相关问题,你可以试着在 [vant discussions](https://github.com/vant-ui/vant/discussions) 新开一个 discussion选择 `Q&A` 类别进行提问。
- name: 2.x
if: github.event.label.name == '2.x'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment, close-issue'
issue-number: ${{ github.event.issue.number }}
body: |
Hi @${{ github.event.issue.user.login }}. Current version (2.x) is off the maintenance period. We will only fix critical bugs. This issue will be auto closed.
你好 @${{ github.event.issue.user.login }}当前版本2.x已经过了维护期。我们仅会修复重要 bug。当前 issue 会被自动关闭。
- name: invalid
if: github.event.label.name == 'invalid'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment, close-issue'
issue-number: ${{ github.event.issue.number }}
body: |
Hello @${{ github.event.issue.user.login }}, your issue has been closed because it does not conform to our issue requirements.
你好 @${{ github.event.issue.user.login }},为了能够进行高效沟通,我们对 issue 有一定的格式要求,你的 issue 因为不符合要求而被自动关闭。

View File

@ -1,20 +0,0 @@
name: PR Labeler
on:
pull_request_target:
types:
- opened
- edited
jobs:
change-labeling:
name: Labeling for changes
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/pr-labeler.yml
enable-versioned-regex: 0
include-title: 1
sync-labels: 1

View File

@ -11,12 +11,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@master
- name: Create Release for Tag
id: release_tag
uses: ncipollo/release-action@v1
uses: yyx990803/release-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
generateReleaseNotes: "true"
tag_name: ${{ github.ref }}
body: |
> Please refer to [Changelog](https://vant-ui.github.io/vant/#/en-US/changelog) for all changes. | 请访问 [更新日志](https://vant-ui.github.io/vant/#/zh-CN/changelog) 了解所有更新。
更新内容参见 [CHANGELOG](https://vant-ui.github.io/vant/#/zh-CN/changelog)。
Please refer to [CHANGELOG](https://vant-ui.github.io/vant/#/en-US/changelog) for details.

View File

@ -2,8 +2,7 @@ name: Sync to Gitee
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
branches: [dev, 2.x, 3.x, gh-pages]
workflow_dispatch:

View File

@ -7,7 +7,7 @@ on:
pull_request:
branches:
- main
- dev
workflow_dispatch:
@ -18,11 +18,11 @@ jobs:
- uses: actions/checkout@v2
- name: Install pnpm
run: corepack enable
run: npm i pnpm@7 -g
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '16'
cache: 'pnpm'
- name: Install dependencies
@ -37,11 +37,11 @@ jobs:
- uses: actions/checkout@v2
- name: Install pnpm
run: corepack enable
run: npm i pnpm@7 -g
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '16'
cache: 'pnpm'
- name: Install dependencies
@ -61,11 +61,11 @@ jobs:
- uses: actions/checkout@v2
- name: Install pnpm
run: corepack enable
run: npm i pnpm@7 -g
- uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '16'
cache: 'pnpm'
- name: Install dependencies

3
.gitignore vendored
View File

@ -17,6 +17,3 @@ lib
dist
**/site-dist
changelog.generated.md
# temp file
packages/vant/README.md

2
.npmrc
View File

@ -1,5 +1,3 @@
registry=https://registry.npmmirror.com/
strict-peer-dependencies=false
auto-install-peers=false
resolution-mode=highest

1
.nvmrc
View File

@ -1 +0,0 @@
lts/Hydrogen

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"proseWrap": "never"
}

View File

@ -4,13 +4,14 @@
<h1 align="center">Vant</h1>
<p align="center">A lightweight, customizable Vue UI library for mobile web apps.</p>
<p align="center">Lightweight Mobile UI Components built on Vue</p>
<p align="center">
<img src="https://img.shields.io/npm/v/vant?style=flat-square" alt="npm version" />
<img src="https://img.shields.io/github/workflow/status/vant-ui/vant/CI/dev?style=flat-square" alt="CI Status" />
<img src="https://img.shields.io/codecov/c/github/vant-ui/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
<img src="https://img.shields.io/npm/dm/vant.svg?style=flat-square&color=#4fc08d" alt="downloads" />
<img src="https://img.badgesize.io/https://unpkg.com/vant/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
<img src="https://img.badgesize.io/https://unpkg.com/vant@3/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
</p>
<p align="center">
@ -26,20 +27,19 @@
## Features
- 🚀 1KB Component average size (min+gzip)
- 🚀 80+ High quality components
- 🚀 70+ High quality components
- 🚀 Zero third-party dependencies
- 💪 90%+ Unit test coverage
- 💪 Written in TypeScript
- 📖 Extensive documentation and demos
- 📖 Provide Sketch and Axure design resources
- 🍭 Support Vue 2 & Vue 3
- 🍭 Support Nuxt 2 & Nuxt 3, provide [Vant Module](https://github.com/vant-ui/vant-nuxt) for Nuxt
- 🍭 Support Tree Shaking
- 🍭 Support Custom Theme
- 🍭 Support Accessibility (still improving)
- 🍭 Support Dark Mode
- 🍭 Support Dark Mode (Requires upgrade to [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/en-US/config-provider))
- 🍭 Support SSR
- 🌍 Support i18n, built-in 30+ languages
- 🌍 Support i18n, built-in 20+ languages
## Install
@ -92,16 +92,16 @@ Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3)
| --- | --- |
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | WeChat MiniProgram UI |
| [vant-demo](https://github.com/vant-ui/vant-demo) | Collection of Vant demos |
| [vant-cli](https://github.com/vant-ui/vant/tree/main/packages/vant-cli) | Scaffold for UI library |
| [vant-icons](https://github.com/vant-ui/vant/tree/main/packages/vant-icons) | Vant icons |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/main/packages/vant-touch-emulator) | Using vant in desktop browsers |
| [vant-nuxt](https://github.com/vant-ui/vant-nuxt) | Vant module for Nuxt |
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | Scaffold for UI library |
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant icons |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | Using vant in desktop browsers |
## Community Ecosystem
| Project | Description |
| --- | --- |
| [3lang3/react-vant](https://github.com/3lang3/react-vant) | React mobile UI Components based on Vant |
| [rc-ui-lib](https://github.com/rancui/rc-ui-lib) | React mobile UI Components based on Vant |
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Alipay MiniProgram UI |
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro |
| [vant-theme](https://github.com/Aisen60/vant-theme) | Online theme preview built on Vant UI |
@ -112,7 +112,7 @@ Vant 3/4 supports modern browsers and Chrome >= 51、iOS >= 10.0 (same as Vue 3)
- [Documentation](https://vant-ui.github.io/vant)
- [Changelog](https://vant-ui.github.io/vant#/en-US/changelog)
- [Discussions](https://github.com/vant-ui/vant/discussions)
- [Gitter](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
## Preview
@ -124,13 +124,9 @@ You can scan the following QR code to access the demo
Core contributors of Vant and Vant Weapp:
| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) |
| :-: | :-: | :-: | :-: | :-: | :-: |
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) |
| [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![JakeLaoyu](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | [![landluck](https://avatars.githubusercontent.com/u/27060081?s=80&v=4)](https://github.com/landluck/) | [![wjw-gavin](https://avatars.githubusercontent.com/u/19986739?s=80&v=4)](https://github.com/wjw-gavin/) | [![inottn](https://avatars.githubusercontent.com/u/18509404?s=80&v=4)](https://github.com/inottn/) | [![zhousg](https://avatars.githubusercontent.com/u/15833290?s=80&v=4)](https://github.com/zhousg/) |
| :-: | :-: | :-: | :-: | :-: | :-: |
| [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | [landluck](https://github.com/landluck/) | [wjw-gavin](https://github.com/wjw-gavin/) | [inottn](https://github.com/inottn/) | [zhousg](https://github.com/zhousg/) |
| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) |
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
## All Contributors
@ -144,10 +140,6 @@ Thanks to the following friends for their contributions to Vant:
Please make sure to read the [Contributing Guide](./.github/CONTRIBUTING.md) before making a pull request.
## Start On Web IDE
[https://github.dev/youzan/vant](https://github.dev/youzan/vant)
## LICENSE
Vant is [MIT](https://github.com/youzan/vant/blob/main/LICENSE) licensed.
[MIT](https://en.wikipedia.org/wiki/MIT_License)

View File

@ -4,13 +4,14 @@
<h1 align="center">Vant</h1>
<p align="center">轻量、可定制的移动端 Vue 组件库</p>
<p align="center">轻量、可的移动端 Vue 组件库</p>
<p align="center">
<img src="https://img.shields.io/npm/v/vant?style=flat-square" alt="npm version" />
<img src="https://img.shields.io/github/workflow/status/vant-ui/vant/CI/dev?style=flat-square" alt="CI Status" />
<img src="https://img.shields.io/codecov/c/github/vant-ui/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
<img src="https://img.shields.io/npm/dm/vant.svg?style=flat-square&color=#4fc08d" alt="downloads" />
<img src="https://img.badgesize.io/https://unpkg.com/vant/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
<img src="https://img.badgesize.io/https://unpkg.com/vant@3/lib/vant.min.js?compression=gzip&style=flat-square&label=gzip%20size&color=#4fc08d" alt="Gzip Size" />
</p>
<p align="center">
@ -23,27 +24,26 @@
### 介绍
Vant 是一个**轻量、可定制的移动端组件库**,于 2017 年开源。
Vant 是一个**轻量、可的移动端组件库**,于 2017 年开源。
目前 Vant 官方提供了 [Vue 2 版本](https://vant-contrib.gitee.io/vant/v2)、[Vue 3 版本](https://vant-contrib.gitee.io/vant)和[微信小程序版本](http://vant-contrib.gitee.io/vant-weapp),并由社区团队维护 [React 版本](https://github.com/3lang3/react-vant)和[支付宝小程序版本](https://github.com/ant-move/Vant-Aliapp)。
## 特性
- 🚀 性能极佳,组件平均体积小于 1KBmin+gzip
- 🚀 80+ 个高质量组件,覆盖移动端主流场景
- 🚀 70+ 个高质量组件,覆盖移动端主流场景
- 🚀 零外部依赖,不依赖三方 npm 包
- 💪 使用 TypeScript 编写,提供完整的类型定义
- 💪 单元测试覆盖率超过 90%,提供稳定性保障
- 📖 提供丰富的中英文文档和组件示例
- 📖 提供 Sketch 和 Axure 设计资源
- 🍭 支持 Vue 2、Vue 3 和微信小程序
- 🍭 支持 Nuxt 2、Nuxt 3提供 Nuxt 的 [Vant Module](https://github.com/vant-ui/vant-nuxt)
- 🍭 支持主题定制,内置 700+ 个主题变量
- 🍭 支持按需引入和 Tree Shaking
- 🍭 支持无障碍访问(持续改进中)
- 🍭 支持深色模式
- 🍭 支持深色模式(从 [Vant 4](https://vant-contrib.gitee.io/vant/v4/#/zh-CN/config-provider) 开始支持)
- 🍭 支持服务器端渲染
- 🌍 支持国际化,内置 30+ 种语言包
- 🌍 支持国际化,内置 20+ 种语言包
## 安装
@ -98,10 +98,9 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
| --- | --- |
| [vant-weapp](https://github.com/vant-ui/vant-weapp) | Vant 微信小程序版 |
| [vant-demo](https://github.com/vant-ui/vant-demo) | Vant 官方示例合集 |
| [vant-cli](https://github.com/vant-ui/vant/tree/main/packages/vant-cli) | 开箱即用的组件库搭建工具 |
| [vant-icons](https://github.com/vant-ui/vant/tree/main/packages/vant-icons) | Vant 图标库 |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/main/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
| [vant-nuxt](https://github.com/vant-ui/vant-nuxt) | 为 Nuxt 准备的模块 |
| [vant-cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli) | 开箱即用的组件库搭建工具 |
| [vant-icons](https://github.com/vant-ui/vant/tree/dev/packages/vant-icons) | Vant 图标库 |
| [vant-touch-emulator](https://github.com/vant-ui/vant/tree/dev/packages/vant-touch-emulator) | 在桌面端使用 Vant 的辅助库 |
## 社区生态
@ -110,6 +109,7 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
| 项目 | 描述 |
| --- | --- |
| [3lang3/react-vant](https://github.com/3lang3/react-vant) | 参照 Vant 打造的 React 框架移动端组件库 |
| [rc-ui-lib](https://github.com/rancui/rc-ui-lib) | 参照 Vant 打造的 React 框架移动端组件库 |
| [vant-aliapp](https://github.com/ant-move/Vant-Aliapp) | Vant 支付宝小程序版 |
| [taroify](https://gitee.com/mallfoundry/taroify) | Vant Taro 版 |
| [vant-theme](https://github.com/Aisen60/vant-theme) | Vant 在线主题预览工具 |
@ -120,8 +120,7 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
- [详细文档](https://vant-contrib.gitee.io/vant)
- [更新日志](https://vant-contrib.gitee.io/vant#/zh-CN/changelog)
- [码云镜像仓库](https://gitee.com/vant-contrib/vant)
- [Discussions 讨论区](https://github.com/vant-ui/vant/discussions)
- [Gitter 讨论组](https://gitter.im/vant-contrib/discuss?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
## 手机预览
@ -133,13 +132,9 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
以下是 Vant 和 Vant Weapp 的核心贡献者们:
| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) |
| :-: | :-: | :-: | :-: | :-: | :-: |
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) |
| [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![JakeLaoyu](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) | [![landluck](https://avatars.githubusercontent.com/u/27060081?s=80&v=4)](https://github.com/landluck/) | [![wjw-gavin](https://avatars.githubusercontent.com/u/19986739?s=80&v=4)](https://github.com/wjw-gavin/) | [![inottn](https://avatars.githubusercontent.com/u/18509404?s=80&v=4)](https://github.com/inottn/) | [![zhousg](https://avatars.githubusercontent.com/u/15833290?s=80&v=4)](https://github.com/zhousg/) |
| :-: | :-: | :-: | :-: | :-: | :-: |
| [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) | [landluck](https://github.com/landluck/) | [wjw-gavin](https://github.com/wjw-gavin/) | [inottn](https://github.com/inottn/) | [zhousg](https://github.com/zhousg/) |
| [![chenjiahan](https://avatars.githubusercontent.com/u/7237365?s=80&v=4)](https://github.com/chenjiahan/) | [![cookfront](https://avatars.githubusercontent.com/u/4829465?s=80&v=4)](https://github.com/cookfront/) | [![w91](https://avatars.githubusercontent.com/u/2599455?s=80&v=4)](https://github.com/w91/) | [![pangxie1991](https://avatars.githubusercontent.com/u/5961240?s=80&v=4)](https://github.com/pangxie1991/) | [![rex-zsd](https://avatars.githubusercontent.com/u/8767877?s=80&v=4)](https://github.com/rex-zsd/) | [![nemo-shen](https://avatars.githubusercontent.com/u/13480805?s=80&v=4)](https://github.com/nemo-shen/) | [![Lindysen](https://avatars.githubusercontent.com/u/33708359?s=80&v=4)](https://github.com/Lindysen/) | [![nemo-shen](https://avatars.githubusercontent.com/u/16181940?s=80&v=4)](https://github.com/JakeLaoyu/) |
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
| [chenjiahan](https://github.com/chenjiahan/) | [cookfront](https://github.com/cookfront/) | [wangnaiyi](https://github.com/w91/) | [pangxie](https://github.com/pangxie1991/) | [rex-zsd](https://github.com/rex-zsd/) | [nemo-shen](https://github.com/nemo-shen/) | [Lindysen](https://github.com/Lindysen/) | [JakeLaoyu](https://github.com/JakeLaoyu/) |
## 贡献者们
@ -155,10 +150,6 @@ Vant 3/4 支持现代浏览器以及 Chrome >= 51、iOS >= 10.0(与 Vue 3 一
使用过程中发现任何问题都可以提 [Issue](https://github.com/vant-ui/vant/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://github.com/vant-ui/vant/pulls)。
## 在 Cloud IDE 中预览
[https://idegithub.com/youzan/vant](https://idegithub.com/youzan/vant)
## 开源协议
本项目基于 [MIT](https://github.com/youzan/vant/blob/main/LICENSE) 协议,请自由地享受和参与开源。
本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。

View File

@ -3,10 +3,9 @@
"scripts": {
"prepare": "husky install",
"dev": "pnpm --dir ./packages/vant dev",
"lint": "eslint ./packages/**/src ./packages/**/test --ext .js,.ts,.tsx,.vue,.mjs,.cjs",
"lint": "pnpm --dir ./packages/vant lint",
"test": "pnpm --dir ./packages/vant test",
"test:watch": "pnpm --dir ./packages/vant test:watch",
"test:update": "pnpm --dir ./packages/vant test:update",
"build": "pnpm --dir ./packages/vant build",
"build:site": "pnpm --dir ./packages/vant build:site"
},
@ -15,16 +14,24 @@
"*.{ts,tsx,js,vue,less}": "prettier --write",
"*.{ts,tsx,js,vue}": "eslint --fix"
},
"engines": {
"pnpm": ">= 8.0.0"
},
"packageManager": "pnpm@8.6.5",
"packageManager": "pnpm@7.11.0",
"devDependencies": {
"@vant/cli": "workspace:*",
"@vant/eslint-config": "workspace:*",
"eslint": "^8.46.0",
"eslint": "^8.23.0",
"husky": "^8.0.1",
"nano-staged": "^0.8.0",
"prettier": "^3.0.0"
"prettier": "^2.7.1",
"rimraf": "^3.0.2"
},
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"@algolia/client-search",
"@types/react",
"react",
"react-dom"
]
}
}
}

View File

@ -15,5 +15,5 @@ test/coverage
es
lib
dist
**/site-dist
site
changelog.generated.md

View File

@ -28,11 +28,11 @@
"*.{ts,tsx,js,vue}": "eslint --fix"
},
"peerDependencies": {
"vue": "^3.3.4"
"vue": "^3.0.0"
},
"devDependencies": {
"@vant/cli": "^6.0.0",
"vue": "^3.3.4",
"@vant/cli": "^4.0.0",
"vue": "^3.0.0",
"sass": "^1.49.7"
},
"eslintConfig": {

View File

@ -1,6 +1,6 @@
{
"name": "create-vant-cli-app",
"version": "2.2.1",
"version": "2.0.1",
"description": "Create Vant CLI App",
"main": "lib/index.js",
"bin": {
@ -9,7 +9,7 @@
"scripts": {
"dev": "tsc --watch",
"build": "rimraf ./lib && tsc",
"release": "vant-cli release",
"release": "pnpm build & release-it",
"prepare": "pnpm build"
},
"files": [
@ -31,15 +31,22 @@
"author": "chenjiahan",
"license": "MIT",
"devDependencies": {
"@types/fs-extra": "^11.0.1",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
"@types/fs-extra": "^9.0.13",
"@types/inquirer": "^8.2.3",
"release-it": "^15.4.1",
"typescript": "^4.8.2"
},
"dependencies": {
"consola": "^3.0.2",
"consola": "^2.11.3",
"fast-glob": "^3.2.11",
"fs-extra": "^11.1.0",
"enquirer": "2.3.6",
"fs-extra": "^10.1.0",
"inquirer": "^8.2.4",
"picocolors": "^1.0.0"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: create-vant-cli-app ${version}"
}
}
}

View File

@ -1,4 +1,4 @@
import { join } from 'node:path';
import { join } from 'path';
export const CWD = process.cwd();
export const GENERATOR_DIR = join(__dirname, '../generators');

View File

@ -1,31 +1,31 @@
import fs from 'fs-extra';
import glob from 'fast-glob';
import color from 'picocolors';
import { consola } from 'consola';
import { prompt } from 'enquirer';
import { sep, join } from 'node:path';
import consola from 'consola';
import { prompt } from 'inquirer';
import { sep, join } from 'path';
import { CWD, GENERATOR_DIR } from './constant';
const PROMPTS = [
{
name: 'vueVersion',
message: 'Select Vue version',
type: 'select',
type: 'list',
choices: [
{
name: 'vue2',
message: 'Vue 2',
name: 'Vue 2',
value: 'vue2',
},
{
name: 'vue3',
message: 'Vue 3',
name: 'Vue 3',
value: 'vue3',
},
],
},
{
name: 'preprocessor',
message: 'Select css preprocessor',
type: 'select',
type: 'list',
choices: ['Less', 'Sass'],
},
];
@ -69,14 +69,14 @@ export class VanGenerator {
// see https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
const templatePath = join(GENERATOR_DIR, this.inputs.vueVersion).replace(
/\\/g,
'/',
'/'
);
const templateFiles = glob.sync(
join(templatePath, '**', '*').replace(/\\/g, '/'),
{
dot: true,
},
}
);
templateFiles.forEach((filePath) => {
@ -109,8 +109,8 @@ export class VanGenerator {
consola.success(`Successfully created ${color.yellow(name)}.`);
consola.success(
`Run ${color.yellow(
`cd ${name} && git init && yarn && yarn dev`,
)} to start development!`,
`cd ${name} && git init && yarn && yarn dev`
)} to start development!`
);
}
}

View File

@ -1,16 +1,20 @@
#!/usr/bin/env node
import { consola } from 'consola';
import { prompt } from 'enquirer';
import consola from 'consola';
import { prompt } from 'inquirer';
import { ensureDir } from 'fs-extra';
import { VanGenerator } from './generator';
async function run() {
const { name } = await prompt<{ name: string }>({
const PROMPTS = [
{
type: 'input',
name: 'name',
message: 'Your package name',
});
},
];
async function run() {
const { name } = await prompt(PROMPTS);
try {
await ensureDir(name);

View File

@ -6,6 +6,5 @@
"module": "commonjs",
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["**/node_modules", "**/.*/"]
"include": ["src/**/*"]
}

View File

@ -1,5 +0,0 @@
export default {
build: {
packageManager: 'pnpm',
},
};

View File

@ -1,6 +1,6 @@
# Vant China Area Data
# Vant Area Data
中国省市区数据,适用于 Vant Area 和 Cascader 等组件。
中国省市区数据,适用于 Vant Area 组件。
## 安装
@ -17,20 +17,10 @@ pnpm add @vant/area-data
## 使用
在 Vant 的 Area 组件中使用时,直接引用 `areaList` 对象即可:
```ts
import { areaList } from '@vant/area-data';
```
在 Vant 的 Cascader 组件中使用时,请使用 `useCascaderAreaData` 方法:
```ts
import { useCascaderAreaData } from '@vant/area-data';
const cascaderAreaData = useCascaderAreaData();
```
## 数据更新
中国的行政区划每年都会有变动,如果发现省市区数据未及时更新,欢迎提 Pull Request 帮助我们更新。你可以在[「国家统计局 - 全国区划代码」](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/) 和[「民政部 - 行政区划代码」](https://www.mca.gov.cn/article/sj/xzqh/1980/)上查询到最新数据,请根据官方数据进行核实。
中国的行政区划每年都会有变动,如果发现省市区数据未及时更新,欢迎提 Pull Request 帮助我们更新。

View File

@ -1,6 +1,6 @@
{
"name": "@vant/area-data",
"version": "1.5.0",
"version": "1.3.2",
"description": "Vant 省市区数据",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
@ -11,7 +11,6 @@
"require": "./dist/index.cjs.js"
}
},
"sideEffects": false,
"files": [
"dist"
],
@ -21,7 +20,7 @@
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
"build:bundle": "node ./build.js",
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
"release": "vant-cli release",
"release": "pnpm build && release-it",
"prepare": "pnpm build"
},
"publishConfig": {
@ -37,8 +36,14 @@
"author": "chenjiahan",
"license": "MIT",
"devDependencies": {
"esbuild": "^0.18.11",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
"esbuild": "^0.14.54",
"release-it": "^15.4.1",
"typescript": "^4.8.2"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/area-data ${version}"
}
}
}

View File

@ -1,8 +1,4 @@
export const areaList: {
province_list: Record<string, string>;
city_list: Record<string, string>;
county_list: Record<string, string>;
} = {
export const areaList = {
province_list: {
110000: '北京市',
120000: '天津市',
@ -1391,10 +1387,11 @@ export const areaList: {
340190: '高新技术开发区',
340191: '经济技术开发区',
340202: '镜湖区',
340203: '弋江区',
340207: '鸠江区',
340209: '弋江区',
340210: '湾沚区',
340212: '繁昌区',
340208: '三山区',
340221: '芜湖县',
340222: '繁昌县',
340223: '南陵县',
340281: '无为市',
340302: '龙子湖区',
@ -1624,6 +1621,7 @@ export const areaList: {
360724: '上犹县',
360725: '崇义县',
360726: '安远县',
360727: '龙南县',
360728: '定南县',
360729: '全南县',
360730: '宁都县',
@ -1633,7 +1631,6 @@ export const areaList: {
360734: '寻乌县',
360735: '石城县',
360781: '瑞金市',
360783: '龙南市',
360802: '吉州区',
360803: '青原区',
360821: '吉安县',
@ -3889,53 +3886,3 @@ export const areaList: {
820204: '圣方济各堂区',
},
};
type CascaderOption = {
text: string;
value: string;
children?: CascaderOption[];
};
const makeOption = (
text: string,
value: string,
children?: CascaderOption[],
): CascaderOption => ({
text,
value,
children,
});
export function useCascaderAreaData() {
const {
city_list: city,
county_list: county,
province_list: province,
} = areaList;
const provinceMap = new Map<string, CascaderOption>();
Object.keys(province).forEach((code) => {
provinceMap.set(code.slice(0, 2), makeOption(province[code], code, []));
});
const cityMap = new Map<string, CascaderOption>();
Object.keys(city).forEach((code) => {
const option = makeOption(city[code], code, []);
cityMap.set(code.slice(0, 4), option);
const province = provinceMap.get(code.slice(0, 2));
if (province) {
province.children!.push(option);
}
});
Object.keys(county).forEach((code) => {
const city = cityMap.get(code.slice(0, 4));
if (city) {
city.children!.push(makeOption(county[code], code));
}
});
return Array.from(provinceMap.values());
}

View File

@ -4,6 +4,5 @@
"outDir": "./dist",
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["**/node_modules", "**/.*/"]
"include": ["src/**/*"]
}

View File

@ -1,5 +0,0 @@
export default {
build: {
packageManager: 'pnpm',
},
};

View File

@ -0,0 +1,8 @@
{
"root": true,
"extends": ["@vant"],
"rules": {
"global-require": 0,
"import/no-dynamic-require": 0
}
}

View File

@ -65,7 +65,7 @@ Please add the followed config to `package.json` file.
## More Details
- [cli](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/commands.md)
- [config](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/config.md)
- [directory structure](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/directory.md)
- [CHANGELOG](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/changelog.md)
- [cli](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/commands.md)
- [config](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/config.md)
- [directory structure](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.md)
- [CHANGELOG](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/changelog.md)

View File

@ -62,7 +62,7 @@ pnpm add @vant/cli -D
## 详细文档
- [命令](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/commands.zh-CN.md)
- [配置指南](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/config.zh-CN.md)
- [目录结构](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/directory.zh-CN.md)
- [更新日志](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/changelog.md)
- [命令](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/commands.zh-CN.md)
- [配置指南](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/config.zh-CN.md)
- [目录结构](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.zh-CN.md)
- [更新日志](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/changelog.md)

View File

@ -1,70 +1,14 @@
# 更新日志
## v6.2.0
`2023-07-29`
- 支持替换 dynamic import 中的文件后缀
- 升级 vite v4.4
- 升级 esbuild v0.18
- 升级 prettier v3
## v6.1.0
`2023-03-19`
- 升级 typescript v5
- 升级 esbuild v0.17
- 升级 vite v4.2
- 优化 tsc 错误日志的格式
## v6.0.1
`2023-03-11`
- 修复编译 `mjs` 或者 `cjs` 时, 替换 vue 文件导入出现重复后缀的问题
## v6.0.0
`2023-02-26`
- vite: 由 v3 升级至 v4
- @vitejs/plugin-vue: 由 v3 升级至 v4
- @vitejs/plugin-vue-jsx: 由 v2 升级至 v3
- 移除 `site.searchConfig` 配置项
- 修复 build 时解析 markdown 可能报错的问题
## v5.1.0
`2022-11-05`
- 支持读取 `vite.config.ts` 文件来自定义 vite 配置
- 修复设置 vite 的 `server.port` 配置项不生效的问题
## v5.0.2
`2022-10-07`
- 修复首次运行 dev 时 vite 引入了两份 Vue 代码导致渲染失败的问题
## v5.0.1
`2022-10-06`
- 修复 jest 版本未正确升级的问题
## v5.0.0
## v5.0.0 (未发布)
### 依赖升级
`2022-10-06`
对以下依赖进行了大版本升级:
- vite: 由 v2 升级至 v3
- jest: 由 v27 升级至 v29
- @vitejs/plugin-vue: 由 v2 升级至 v3
- @vitejs/plugin-vue-jsx: 由 v1 升级至 v2
- vite v3
- @vitejs/plugin-vue v3
- @vitejs/plugin-vue-jsx v2
### 依赖精简

View File

@ -29,10 +29,6 @@ const DEFAULT_CONFIG = {
],
coverageReporters: ['html', 'lcov', 'text-summary'],
coverageDirectory: './test/coverage',
testEnvironmentOptions: {
// https://stackoverflow.com/questions/72428323/jest-referenceerror-vue-is-not-defined
customExportConditions: ['node', 'node-addons'],
},
};
function readRootConfig() {

View File

@ -35,7 +35,7 @@ const transformSFC = (code, path) => {
if (descriptor.script) {
const content = descriptor.script.content.replace(
'export default',
'const script =',
'const script ='
);
output.push(content);
} else if (descriptor.scriptSetup) {
@ -87,8 +87,6 @@ module.exports = {
if (isJsxFile(path)) {
code = transformJsx(code, path);
}
return {
code: transformScript(code),
};
return transformScript(code);
},
};

View File

@ -14,13 +14,11 @@ function getPostcssPlugins(rootConfig) {
const plugins = rootConfig.plugins || [];
if (Array.isArray(plugins)) {
const hasAutoprefixerPlugin = plugins.find((plugin) => {
if (typeof plugin === 'object') {
return plugin.postcssPlugin === 'autoprefixer';
}
return plugin === 'autoprefixer';
});
if (hasAutoprefixerPlugin) {
const hasPostcssPlugin = plugins.find(
(plugin) =>
plugin === 'autoprefixer' && plugin.postcssPlugin === 'autoprefixer'
);
if (hasPostcssPlugin) {
return plugins;
}

View File

@ -29,7 +29,7 @@ Start local dev server for browsering components and demo.
Build Vue component library.
Files will be output to `es` and `lib` directory. More details [directory structure](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/directory.md)
Files will be output to `es` and `lib` directory. More details [directory structure](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.md)
Please add the followed config to `package.json` when publish to npm.
@ -48,7 +48,11 @@ Build documentation website. Files will be output to `site` directory.
### release
Publish to npm. `build` will be automatically execute when run `release`.
Publish to npm. `build` and `changelog` will be automatically execute when run `release`.
### changelog
Generate changelog based on commit records.
### commit-lint

View File

@ -31,7 +31,7 @@ npx vant-cli dev
构建组件库。
运行 build 命令会在 `es``lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/vant-ui/vant/tree/main/packages/vant-cli/docs/directory.zh-CN.md)。
运行 build 命令会在 `es``lib` 目录下生成可用于生产环境的组件代码,详见 [目录结构](https://github.com/vant-ui/vant/tree/dev/packages/vant-cli/docs/directory.zh-CN.md)。
发布 npm 时,请将以下配置加入到 `package.json` 中,使 npm 包能被正确识别:
@ -50,7 +50,11 @@ npx vant-cli dev
### release
发布组件库,发布前会自动执行 build 命令,并按照流程发布 npm 包。
发布组件库,发布前会自动执行 build 和 changelog 命令,并通过 [release-it](https://github.com/release-it/release-it) 发布 npm 包。
### changelog
基于 commit 记录生成更新日志,基于 [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) 实现。
### commit-lint

View File

@ -16,6 +16,7 @@
- [site.nav](#sitenav)
- [site.versions](#siteversions)
- [site.baiduAnalytics](#sitebaiduanalytics)
- [site.searchConfig](#sitesearchconfig)
- [site.hideSimulator](#sitehidesimulator)
- [site.simulator.url](#sitesimulatorurl)
- [site.htmlMeta](#sitehtmlmeta)
@ -176,16 +177,17 @@ When set to `true`, `export * from 'xxx'` will be used to export all modules and
### build.configureVite
- Type: `(config: InlineConfig): InlineConfig | undefined`
- Type: `(config: InlineConfig): InlineConfig`
- Default: `undefined`
Custom [vite config](https://vitejs.dev/config/), requires `@vant/cli>= 4.0.0`.
Custom vite config(`@vant/cli>= 4.0.0`)
```js
module.exports = {
build: {
configureVite(config) {
config.server.port = 3000;
// add vite plugin
config.plugins.push(vitePluginXXX);
return config;
},
},
@ -212,14 +214,10 @@ module.exports = {
};
```
Note that you are not allowed to import vite plugins in `vant.config.mjs`, because the file will be bundled into the website code.
If you need to configure some vite plugins, please create a `vite.config.ts` file in the same directory of `vant.config.mjs`, in which you can add any vite configuration (this feature requires @vant/cli 5.1.0).
### build.packageManager
- Type: `'npm' | 'yarn' | 'pnpm'`
- Default: `yarn`
- Default: `undefined`
`npm` package manager.
@ -354,6 +352,13 @@ module.exports = {
};
```
### site.searchConfig
- Type: `object`
- Default: `undefined`
Documentation site search config. Based on [docsearch](https://docsearch.algolia.com/docs/behavior) of algolia.
### site.hideSimulator
- Type: `boolean`

View File

@ -16,6 +16,7 @@
- [site.nav](#sitenav)
- [site.versions](#siteversions)
- [site.baiduAnalytics](#sitebaiduanalytics)
- [site.searchConfig](#sitesearchconfig)
- [site.hideSimulator](#sitehidesimulator)
- [site.simulator.url](#sitesimulatorurl)
- [site.htmlMeta](#sitehtmlmeta)
@ -176,16 +177,17 @@ module.exports = {
### build.configureVite
- Type: `(config: InlineConfig): InlineConfig | undefined`
- Type: `(config: InlineConfig): InlineConfig`
- Default: `undefined`
vant-cli 使用 vite 来构建组件库和文档站点,通过 `configureVite` 选项可以自定义 [vite 配置](https://vitejs.dev/config/)(从 4.0.0 版本开始支持)。
vant-cli 使用 vite 来构建组件库和文档站点,通过 `configureVite` 选项可以自定义 vite 配置(从 4.0.0 版本开始支持)。
```js
module.exports = {
build: {
configureVite(config) {
config.server.port = 3000;
// 添加一个自定义插件
config.plugins.push(vitePluginXXX);
return config;
},
},
@ -214,14 +216,10 @@ module.exports = {
};
```
注意,由于 `vant.config.mjs` 文件会被打包到文档网站的代码中,因此 `configureVite` 中不允许引用 vite 插件。
如果需要配置 vite 插件,可以在 `vant.config.mjs` 的同级目录下创建 `vite.config.ts` 文件,在该文件中你可以添加任意的 vite 配置(该特性从 @vant/cli 5.1.0 版本开始支持)。
### build.packageManager
- Type: `'npm' | 'yarn' | 'pnpm'`
- Default: `yarn`
- Default: `undefined`
指定使用的包管理器。
@ -356,6 +354,15 @@ module.exports = {
};
```
### site.searchConfig
- Type: `object`
- Default: `undefined`
文档网站的搜索配置,基于 algolia 提供的 docsearch 服务实现。
配置内容参见 [docsearch](https://docsearch.algolia.com/docs/behavior)。
### site.hideSimulator
- Type: `boolean`

View File

@ -1,6 +1,6 @@
{
"name": "@vant/cli",
"version": "6.2.0",
"version": "4.0.4",
"type": "module",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
@ -13,13 +13,14 @@
"scripts": {
"dev": "tsc --watch",
"build": "rimraf ./lib && tsc",
"release": "vant-cli release",
"release": "pnpm build & release-it",
"prepare": "pnpm build"
},
"files": [
"lib",
"cjs",
"site",
"template",
"bin.js"
],
"keywords": [
@ -38,54 +39,61 @@
"author": "chenjiahan",
"license": "MIT",
"devDependencies": {
"@jest/types": "^29.1.2",
"@types/fs-extra": "^11.0.1",
"@jest/types": "^27.5.1",
"@types/fs-extra": "^9.0.13",
"@types/less": "^3.0.3",
"@types/lodash": "^4.14.191",
"@types/markdown-it": "^12.2.3",
"rimraf": "^5.0.0",
"vue": "^3.3.4"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"vue": "^3.2.38"
},
"dependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-typescript": "^7.18.6",
"@types/jest": "^29.5.1",
"@vant/eslint-config": "^4.0.0",
"@docsearch/css": "^3.2.1",
"@docsearch/js": "^3.2.1",
"@types/jest": "^27.5.2",
"@vant/eslint-config": "^3.5.0",
"@vant/touch-emulator": "^1.4.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"@vitejs/plugin-vue": "^3.0.3",
"@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/babel-plugin-jsx": "^1.1.1",
"autoprefixer": "^10.4.8",
"commander": "^10.0.0",
"consola": "^3.0.2",
"esbuild": "^0.18.11",
"eslint": "^8.46.0",
"execa": "^6.1.0",
"enquirer": "2.3.6",
"commander": "^9.4.0",
"consola": "^2.15.3",
"conventional-changelog": "^3.1.25",
"esbuild": "^0.14.54",
"eslint": "^8.23.0",
"execa": "^5.1.1",
"fast-glob": "^3.2.11",
"fs-extra": "^11.1.0",
"fs-extra": "^10.1.0",
"hash-sum": "^2.0.0",
"highlight.js": "^11.6.0",
"husky": "^8.0.1",
"jest": "^29.5.0",
"jest": "^27.5.1",
"jest-canvas-mock": "^2.4.0",
"jest-environment-jsdom": "^29.1.2",
"jest-serializer-html": "^7.1.0",
"less": "^4.1.3",
"lodash": "^4.17.21",
"markdown-it": "^12.3.2",
"markdown-it-anchor": "^8.6.4",
"nano-staged": "^0.8.0",
"nanospinner": "^1.1.0",
"picocolors": "^1.0.0",
"postcss": "^8.4.23",
"postcss-load-config": "^4.0.1",
"prettier": "^3.0.0",
"terser": "^5.16.1",
"postcss": "^8.4.16",
"postcss-load-config": "^3.1.4",
"prettier": "^2.7.1",
"release-it": "^15.4.1",
"transliteration": "^2.3.5",
"typescript": "^5.0.4",
"vite": "^4.4.2",
"typescript": "^4.8.2",
"vite": "^3.0.9",
"vite-plugin-html": "^2.1.2",
"vite-plugin-md": "^0.11.9",
"vue-router": "^4.1.6"
"vue-router": "^4.1.5"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/cli ${version}"
}
}
}

View File

@ -40,7 +40,7 @@ export function syncPathToParent() {
type: 'replacePath',
value: getCurrentDir(),
},
'*',
'*'
);
}
@ -53,7 +53,7 @@ export function syncPathToChild() {
type: 'replacePath',
value: getCurrentDir(),
},
'*',
'*'
);
});
}
@ -68,7 +68,7 @@ export function syncThemeToChild(theme) {
type: 'updateTheme',
value: theme,
},
'*',
'*'
);
});
}

View File

@ -6,20 +6,9 @@ body {
overflow-x: auto;
color: var(--van-doc-text-color-2);
font-size: 16px;
font-family:
'Open Sans',
-apple-system,
BlinkMacSystemFont,
'Helvetica Neue',
Helvetica,
Segoe UI,
Arial,
Roboto,
'PingFang SC',
'miui',
'Hiragino Sans GB',
'Microsoft Yahei',
sans-serif;
font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui',
'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
background-color: var(--van-doc-background);
-webkit-font-smoothing: antialiased;
}

View File

@ -6,7 +6,7 @@ code {
color: var(--van-doc-code-color);
font-weight: 400;
font-size: 14px;
font-family: var(--van-doc-code-font-family);
font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
line-height: 26px;
white-space: pre-wrap;
word-wrap: break-word;
@ -15,13 +15,6 @@ code {
border-radius: var(--van-doc-border-radius);
}
p {
code {
display: inline-flex;
padding: 4px 10px;
}
}
pre {
margin: 20px 0 0;

View File

@ -1,4 +1,4 @@
:root {
body {
// colors
--van-doc-black: #000;
--van-doc-white: #fff;
@ -12,20 +12,15 @@
--van-doc-gray-8: #323233;
--van-doc-blue: #1989fa;
--van-doc-green: #07c160;
--van-doc-purple: #8e69d3;
// sizes
--van-doc-padding: 32px;
--van-doc-padding: 24px;
--van-doc-row-max-width: 1680px;
--van-doc-nav-width: 220px;
--van-doc-border-radius: 20px;
--van-doc-simulator-width: 360px;
--van-doc-simulator-height: 620px;
--van-doc-header-top-height: 64px;
// fonts
--van-doc-code-font-family: 'Menlo', 'Source Code Pro', 'Monaco',
'Inconsolata', monospace;
}
.van-doc-theme-light {
@ -49,7 +44,7 @@
--van-doc-code-background: var(--van-doc-gray-1);
// blockquote
--van-doc-blockquote-color: #2f85da;
--van-doc-blockquote-color: #4994df;
--van-doc-blockquote-background: #ecf9ff;
}

View File

@ -107,11 +107,11 @@ export default {
const navItems = this.config.nav.reduce(
(result, nav) => [...result, ...nav.items],
[],
[]
);
const current = navItems.find(
(item) => item.path === this.$route.meta.name,
(item) => item.path === this.$route.meta.name
);
if (current && current.title) {

View File

@ -12,11 +12,6 @@ import { copyToClipboard } from '../../common';
export default {
name: 'VanDocContent',
data() {
return {
iframeDocument: null,
};
},
computed: {
currentPage() {
@ -55,22 +50,6 @@ export default {
name: this.$route.name,
hash: '#' + target.id,
});
this.syncMobilePos(target.id);
}
},
syncMobilePos(id) {
// Getting the document at this point is to ensure that the target has been fully rendered.
if (!this.iframeDocument) {
const iframe = document.querySelector('iframe');
this.iframeDocument = iframe.contentWindow.document;
}
if (this.iframeDocument) {
const target = this.iframeDocument.getElementById(id);
if (target) {
target.scrollIntoView(true);
}
}
},
@ -104,8 +83,8 @@ export default {
<style lang="less">
.van-doc-card {
margin-bottom: var(--van-doc-padding);
padding: 28px 28px 32px;
margin-bottom: 24px;
padding: 24px;
background-color: var(--van-doc-background-2);
border-radius: var(--van-doc-border-radius);
overflow: auto;
@ -206,7 +185,7 @@ export default {
}
> p {
margin-top: 16px;
margin-top: 8px;
color: var(--van-doc-text-color-3);
font-size: 15px;
line-height: 26px;
@ -266,7 +245,7 @@ export default {
display: inline-block;
color: var(--van-doc-green);
font-size: 14px;
font-family: var(--van-doc-code-font-family);
font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
font-style: normal;
max-width: 300px;
-webkit-font-smoothing: auto;
@ -274,7 +253,7 @@ export default {
}
> ul {
margin: 16px 0 0;
margin: 12px 0;
}
> ul li,
@ -312,19 +291,19 @@ export default {
> table code {
display: inline;
margin: 0 2px;
padding: 3px 7px;
padding: 2px 5px;
font-size: 14px;
font-family: inherit;
font-weight: 600;
word-break: keep-all;
border-radius: 6px;
-webkit-font-smoothing: auto;
font-family: var(--van-doc-code-font-family);
border-radius: 4px;
-webkit-font-smoothing: antialiased;
}
> blockquote {
margin: 16px 0 0;
padding: 16px;
font-size: 15px;
line-height: 26px;
font-size: 14px;
color: var(--van-doc-blockquote-color);
background-color: var(--van-doc-blockquote-background);
border-radius: var(--van-doc-border-radius);
@ -333,7 +312,7 @@ export default {
> img,
> p img {
width: 100%;
margin: 16px 0 0;
margin: 16px 0;
border-radius: var(--van-doc-border-radius);
}
}
@ -344,7 +323,7 @@ export default {
padding: 0 0 75px;
.van-doc-markdown-body {
padding: var(--van-doc-padding);
padding: 24px;
overflow: hidden;
h1,
@ -364,7 +343,7 @@ export default {
}
h2 {
margin: 52px 0 20px;
margin: 45px 0 20px;
font-size: 26px;
}
}

View File

@ -108,9 +108,7 @@ export default {
cursor: pointer;
opacity: 0.6;
outline: none;
transition:
opacity 0.2s,
background 0.2s;
transition: opacity 0.2s, background 0.2s;
// expand click area
&::after {

View File

@ -64,6 +64,12 @@
{{ langLabel }}
</a>
</li>
<search-input
v-if="searchConfig"
:lang="lang"
:search-config="searchConfig"
/>
</ul>
</div>
</div>
@ -71,12 +77,17 @@
</template>
<script>
import SearchInput from './SearchInput.vue';
import { packageVersion } from 'site-desktop-shared';
import { getDefaultTheme, syncThemeToChild } from '../../common/iframe-sync';
export default {
name: 'VanDocHeader',
components: {
SearchInput,
},
props: {
lang: String,
config: Object,
@ -111,6 +122,10 @@ export default {
return {};
},
searchConfig() {
return this.config.searchConfig;
},
themeImg() {
if (this.currentTheme === 'light') {
return 'https://b.yzcdn.cn/vant/dark-theme.svg';
@ -123,8 +138,8 @@ export default {
currentTheme: {
handler(newVal, oldVal) {
window.localStorage.setItem('vantTheme', newVal);
document.documentElement.classList.remove(`van-doc-theme-${oldVal}`);
document.documentElement.classList.add(`van-doc-theme-${newVal}`);
document.body.classList.remove(`van-doc-theme-${oldVal}`);
document.body.classList.add(`van-doc-theme-${newVal}`);
syncThemeToChild(newVal);
},
immediate: true,
@ -142,7 +157,7 @@ export default {
const action = val ? 'add' : 'remove';
document.body[`${action}EventListener`](
'click',
this.checkHideVersionPop,
this.checkHideVersionPop
);
this.showVersionPop = val;
@ -172,8 +187,6 @@ export default {
width: 100%;
background-color: var(--van-doc-header-background);
user-select: none;
position: relative;
z-index: 2;
&__top {
display: flex;

View File

@ -1,5 +1,5 @@
<template>
<div :class="['van-doc-nav', { 'van-doc-nav-fixed': isFixed }]">
<div class="van-doc-nav" :style="style">
<div
v-for="(group, index) in navConfig"
class="van-doc-nav__group"
@ -38,11 +38,19 @@ export default {
data() {
return {
isFixed: false,
top: 64,
bottom: 0,
};
},
computed: {
style() {
return {
top: this.top + 'px',
bottom: this.bottom + 'px',
};
},
base() {
return this.lang ? `/${this.lang}/` : '/';
},
@ -56,7 +64,7 @@ export default {
methods: {
onScroll() {
const { pageYOffset: offset } = window;
this.isFixed = offset > 64;
this.top = Math.max(0, 64 - offset);
},
},
};
@ -64,10 +72,8 @@ export default {
<style lang="less">
.van-doc-nav {
position: absolute;
position: fixed;
left: 0;
top: var(--van-doc-header-top-height);
bottom: 0;
z-index: 1;
min-width: var(--van-doc-nav-width);
max-width: var(--van-doc-nav-width);
@ -80,10 +86,6 @@ export default {
margin-left: calc((var(--van-doc-row-max-width) / 2 * -1));
}
&.van-doc-nav-fixed {
position: fixed;
top: 0;
}
&::-webkit-scrollbar {
width: 6px;
height: 6px;
@ -108,14 +110,14 @@ export default {
padding: 24px 0 0 var(--van-doc-padding);
color: var(--van-doc-text-color-2);
font-weight: 600;
font-size: 16px;
font-size: 15px;
line-height: 28px;
}
&__item {
a {
display: block;
margin: 4px 0;
margin: 8px 0;
padding: 6px 0 6px var(--van-doc-padding);
color: var(--van-doc-text-color-3);
font-size: 14px;

View File

@ -0,0 +1,63 @@
<template>
<div id="docsearch" />
</template>
<script>
export default {
name: 'VanDocSearch',
props: {
lang: String,
searchConfig: Object,
},
watch: {
lang() {
this.initDocsearch();
},
},
mounted() {
this.initDocsearch();
},
methods: {
initDocsearch() {
if (this.searchConfig) {
import('@docsearch/css');
import('@docsearch/js').then((docsearch) => {
docsearch.default({
...this.searchConfig,
container: '#docsearch',
});
});
}
},
},
};
</script>
<style lang="less">
#docsearch {
display: inline-block;
vertical-align: middle;
}
.DocSearch-Button {
height: 32px;
background: #f7f8fa;
&:hover {
box-shadow: none;
}
}
.DocSearch-Search-Icon {
width: 18px;
height: 18px;
}
.DocSearch-Button-Key {
font-size: 12px;
}
</style>

View File

@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@ -11,11 +11,14 @@
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
/>
<%= meta %>
<%- meta %>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<% if (headHtml) { %> <%= headHtml %> <% } %> <% if (baiduAnalytics) { %>
<% if (headHtml) { %>
<%- headHtml %>
<% } %>
<% if (baiduAnalytics) { %>
<script>
var _hmt = _hmt || [];
(function () {

View File

@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@ -11,16 +11,20 @@
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
/>
<%= meta %>
<%- meta %>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<% if (headHtml) { %> <%= headHtml %> <% } %> <% if (enableVConsole) { %>
<% if (headHtml) { %>
<%- headHtml %>
<% } %>
<% if (enableVConsole) { %>
<script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
<script>
var vConsole = new window.VConsole();
</script>
<% } %> <% if (baiduAnalytics) { %>
<% } %>
<% if (baiduAnalytics) { %>
<script>
// avoid to load analytics in iframe
if (window.top === window) {

View File

@ -1,11 +1,11 @@
<template>
<demo-nav />
<router-view v-slot="{ Component }">
<demo-section>
<keep-alive>
<keep-alive>
<demo-section>
<component :is="Component" />
</keep-alive>
</demo-section>
</demo-section>
</keep-alive>
</router-view>
</template>
@ -24,24 +24,15 @@ export default {
watch(
theme,
(newVal, oldVal) => {
document.documentElement.classList.remove(`van-doc-theme-${oldVal}`);
document.documentElement.classList.add(`van-doc-theme-${newVal}`);
document.body.classList.remove(`van-doc-theme-${oldVal}`);
document.body.classList.add(`van-doc-theme-${newVal}`);
const { darkModeClass, lightModeClass } = config.site;
const { darkModeClass } = config.site;
if (darkModeClass) {
document.documentElement.classList.toggle(
darkModeClass,
newVal === 'dark',
);
}
if (lightModeClass) {
document.documentElement.classList.toggle(
lightModeClass,
newVal === 'light',
);
document.body.classList.toggle(darkModeClass, newVal === 'dark');
}
},
{ immediate: true },
{ immediate: true }
);
},
};
@ -52,7 +43,6 @@ export default {
body {
min-width: 100vw;
background-color: inherit;
}
.van-doc-theme-light {

View File

@ -1,8 +1,6 @@
<template>
<div class="van-doc-demo-block">
<h2 v-if="title" class="van-doc-demo-block__title" :id="slugifyTitle">
{{ title }}
</h2>
<h2 v-if="title" class="van-doc-demo-block__title">{{ title }}</h2>
<div v-if="card" class="van-doc-demo-block__card">
<slot />
</div>
@ -18,39 +16,6 @@ export default {
card: Boolean,
title: String,
},
data() {
return {
slugify: null,
};
},
computed: {
slugifyTitle() {
return this.slugify ? this.slugify(this.title) : '';
},
},
watch: {
slugifyTitle(newVal) {
if (newVal) {
this.$nextTick(() => {
let hash = '';
if (top) hash = top.location.hash.split('#').pop();
else hash = location.hash.split('#').pop();
const target = document.getElementById(newVal);
if (target && newVal === hash) {
target.scrollIntoView(true);
}
});
}
},
},
async mounted() {
const { slugify } = await import('transliteration');
this.slugify = slugify;
},
};
</script>

View File

@ -93,7 +93,6 @@ export default {
margin: 0 0 40px;
color: var(--van-doc-text-color-4);
font-size: 14px;
line-height: 1.6;
}
}
</style>

View File

@ -27,27 +27,23 @@ program
.description('Run unit tests through jest')
.option(
'--watch',
'Watch files for changes and rerun tests related to changed files',
'Watch files for changes and rerun tests related to changed files'
)
.option(
'--clearCache',
'Clears the configured Jest cache directory and then exits',
'Clears the configured Jest cache directory and then exits'
)
.option(
'--changedSince <changedSince>',
'Runs tests related to the changes since the provided branch or commit hash',
'Runs tests related to the changes since the provided branch or commit hash'
)
.option(
'--logHeapUsage',
'Logs the heap usage after every test. Useful to debug memory leaks',
'Logs the heap usage after every test. Useful to debug memory leaks'
)
.option(
'--runInBand',
'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests',
)
.option(
'--updateSnapshot',
'Re-record every snapshot that fails during this test run',
'Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests'
)
.option('--debug', 'Print debugging info about your Jest config')
.action(async (options) => {
@ -75,7 +71,6 @@ program
.command('release')
.description('Compile components and release it')
.option('--tag <tag>', 'Release tag')
.option('--gitTag', 'Generate git tag')
.action(async (options) => {
const { release } = await import('./commands/release.js');
return release(options);
@ -89,6 +84,14 @@ program
return buildSite();
});
program
.command('changelog')
.description('Generate changelog')
.action(async () => {
const { changelog } = await import('./commands/changelog.js');
return changelog();
});
program
.command('commit-lint <gitParams>')
.description('Lint commit message')

View File

@ -1,6 +1,6 @@
import fse from 'fs-extra';
import { execa } from 'execa';
import { join, relative } from 'node:path';
import execa from 'execa';
import { join, relative } from 'path';
import { clean } from './clean.js';
import { CSS_LANG } from '../common/css.js';
import { createSpinner, consola } from '../common/logger.js';
@ -66,7 +66,7 @@ async function preCompileDir(dir: string) {
return compileSfc(filePath);
}
return Promise.resolve();
}),
})
);
}
@ -78,7 +78,7 @@ async function compileDir(dir: string, format: Format) {
return isDir(filePath)
? compileDir(filePath, format)
: compileFile(filePath, format);
}),
})
);
}
@ -104,10 +104,7 @@ async function buildTypeDeclarations() {
const tsConfig = join(process.cwd(), 'tsconfig.declaration.json');
if (existsSync(tsConfig)) {
await execa('tsc', ['-p', tsConfig], {
stdout: 'inherit',
stderr: 'inherit',
});
await execa('tsc', ['-p', tsConfig]);
}
}

View File

@ -0,0 +1,77 @@
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { ROOT } from '../common/constant.js';
import { createSpinner, slimPath } from '../common/logger.js';
import { createWriteStream, readFileSync } from 'fs';
import conventionalChangelog from 'conventional-changelog';
const DIST_FILE = join(ROOT, './changelog.generated.md');
const __dirname = dirname(fileURLToPath(import.meta.url));
const MAIN_TEMPLATE = join(__dirname, '../../template/changelog-main.hbs');
const HEADER_TEMPLATE = join(__dirname, '../../template/changelog-header.hbs');
const COMMIT_TEMPLATE = join(__dirname, '../../template/changelog-commit.hbs');
const mainTemplate = readFileSync(MAIN_TEMPLATE, 'utf-8');
const headerPartial = readFileSync(HEADER_TEMPLATE, 'utf-8');
const commitPartial = readFileSync(COMMIT_TEMPLATE, 'utf-8');
function formatType(type: string) {
const MAP: Record<string, string> = {
fix: 'Bug Fixes',
feat: 'Feature',
docs: 'Document',
types: 'Types',
};
return MAP[type] || type;
}
function transform(item: any) {
if (item.type === 'chore' || item.type === 'test') {
return null;
}
item.type = formatType(item.type);
if (item.hash) {
item.shortHash = item.hash.slice(0, 6);
}
if (item.references.length) {
item.references.forEach((ref: any) => {
if (ref.issue && item.subject) {
item.subject = item.subject.replace(` (#${ref.issue})`, '');
}
});
}
return item;
}
export async function changelog(): Promise<void> {
const spinner = createSpinner('Generating changelog...').start();
return new Promise((resolve) => {
conventionalChangelog(
{
preset: 'angular',
releaseCount: 2,
},
null,
null,
null,
{
mainTemplate,
headerPartial,
commitPartial,
transform,
}
)
.pipe(createWriteStream(DIST_FILE))
.on('close', () => {
spinner.success({
text: `Changelog generated at ${slimPath(DIST_FILE)}`,
});
resolve();
});
});
}

View File

@ -1,4 +1,4 @@
import { readFileSync } from 'node:fs';
import { readFileSync } from 'fs';
import { consola } from '../common/logger.js';
const commitRE =

View File

@ -24,7 +24,6 @@ export function test(command: Config.Argv) {
clearCache: command.clearCache,
changedSince: command.changedSince,
logHeapUsage: command.logHeapUsage,
updateSnapshot: command.updateSnapshot,
// make jest tests faster
// see: https://ivantanev.com/make-jest-faster/
maxWorkers: '50%',

View File

@ -1,4 +1,4 @@
import { execa } from 'execa';
import execa from 'execa';
import { consola, createSpinner } from '../common/logger.js';
import { SCRIPT_EXTS } from '../common/constant.js';
@ -11,14 +11,14 @@ type RunCommandMessages = {
function runCommand(
cmd: string,
options: string[],
messages: RunCommandMessages,
messages: RunCommandMessages
) {
const spinner = createSpinner(messages.start).start();
return new Promise((resolve) => {
execa(cmd, options, {
preferLocal: true,
env: { FORCE_COLOR: 'true' },
env: { FORCE_COLOR: true },
})
.then(() => {
spinner.success({ text: messages.succeed });
@ -40,7 +40,7 @@ function eslint() {
start: 'Running eslint...',
succeed: 'ESLint Passed.',
failed: 'ESLint failed!',
},
}
);
}

View File

@ -1,117 +1,22 @@
import fse from 'fs-extra';
import { join } from 'node:path';
import color from 'picocolors';
import enquirer from 'enquirer';
import { consola } from '../common/logger.js';
import { getPackageManager } from '../common/manager.js';
import { execSync } from 'child_process';
/* eslint-disable no-template-curly-in-string */
import releaseIt from 'release-it';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
function logCurrentVersion(cwd: string) {
const pkgJson = join(cwd, 'package.json');
const pkg = fse.readJSONSync(pkgJson);
consola.success(`${color.bold('Current package:')} ${color.green(pkg.name)}`);
consola.success(
`${color.bold('Current version:')} ${color.green(pkg.version)}`,
);
return {
pkgName: pkg.name,
currentVersion: pkg.version,
};
}
const __dirname = dirname(fileURLToPath(import.meta.url));
const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
async function getNewVersion() {
const { version } = await enquirer.prompt<{ version: string }>({
type: 'input',
name: 'version',
message: 'Version to release:',
export async function release(command: { tag?: string }) {
await releaseIt({
plugins: {
[PLUGIN_PATH]: {},
},
npm: {
tag: command.tag,
},
git: {
tagName: 'v${version}',
commitMessage: 'release: ${version}',
},
});
return version;
}
function getNpmTag(version: string, forceTag?: string) {
let tag: string;
if (forceTag) {
tag = forceTag;
} else if (version.includes('beta')) {
tag = 'beta';
} else if (version.includes('alpha')) {
tag = 'alpha';
} else if (version.includes('rc')) {
tag = 'rc';
} else {
tag = 'latest';
}
consola.success(`${color.bold('Npm tag:')} ${color.green(tag)}`);
return tag;
}
function setPkgVersion(version: string, cwd: string) {
const pkgJson = join(cwd, 'package.json');
const pkg = fse.readJSONSync(pkgJson);
pkg.version = version;
fse.writeJSONSync(pkgJson, pkg, { spaces: 2 });
}
function buildPackage(packageManager: string) {
const command = `${packageManager} run build`;
consola.success(`${color.bold('Build package:')} ${color.green(command)}`);
execSync(command, { stdio: 'inherit' });
}
function publishPackage(packageManager: string, tag: string) {
let command = `${packageManager} publish --tag ${tag}`;
if (packageManager === 'pnpm') {
command += ' --no-git-checks';
}
execSync(command, { stdio: 'inherit' });
}
function commitChanges(pkgName: string, version: string, gitTag?: boolean) {
const message = `release: ${pkgName} v${version}`;
execSync(`git add -A && git commit -m "${message}"`, { stdio: 'inherit' });
if (gitTag) {
execSync(`git tag -a v${version} -m "${message}"`, { stdio: 'inherit' });
}
}
function getCurrentBranch() {
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
return branch;
}
function pushChanges(gitTag?: boolean) {
const branch = getCurrentBranch();
execSync(`git push origin ${branch}`, { stdio: 'inherit' });
if (gitTag) {
execSync(`git push origin ${branch} --tags`, { stdio: 'inherit' });
}
}
export async function release(command: { tag?: string; gitTag?: boolean }) {
const cwd = process.cwd();
const { pkgName, currentVersion } = logCurrentVersion(cwd);
const version = await getNewVersion();
const tag = getNpmTag(version, command.tag);
const packageManager = getPackageManager();
setPkgVersion(version, cwd);
try {
buildPackage(packageManager);
} catch (err) {
consola.error('Failed to build package, rollback to the previous version.');
setPkgVersion(currentVersion, cwd);
throw err;
}
publishPackage(packageManager, tag);
commitChanges(pkgName, version, command.gitTag);
pushChanges(command.gitTag);
}

View File

@ -1,6 +1,6 @@
import { existsSync, readFileSync } from 'node:fs';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { join, dirname, isAbsolute } from 'node:path';
import { existsSync, readFileSync } from 'fs';
import { fileURLToPath, pathToFileURL } from 'url';
import { join, dirname, isAbsolute } from 'path';
function findRootDir(dir: string): string {
if (existsSync(join(dir, 'vant.config.mjs'))) {

View File

@ -1,5 +1,5 @@
import { existsSync } from 'node:fs';
import { join, isAbsolute } from 'node:path';
import { existsSync } from 'fs';
import { join, isAbsolute } from 'path';
import { getVantConfig } from '../common/index.js';
import { STYLE_DIR, SRC_DIR } from './constant.js';
@ -39,6 +39,6 @@ const IMPORT_STYLE_RE = /import\s+?(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
// "import 'a.less';" => "import 'a.css';"
export function replaceCSSImportExt(code: string) {
return code.replace(IMPORT_STYLE_RE, (str) =>
str.replace(`.${CSS_LANG}`, '.css'),
str.replace(`.${CSS_LANG}`, '.css')
);
}

View File

@ -1,7 +1,7 @@
import fse from 'fs-extra';
import { sep, join } from 'node:path';
import { sep, join } from 'path';
import { SRC_DIR, getVantConfig } from './constant.js';
import { InlineConfig, loadConfigFromFile, mergeConfig } from 'vite';
import type { InlineConfig } from 'vite';
const { lstatSync, existsSync, readdirSync, readFileSync, outputFileSync } =
fse;
@ -42,7 +42,7 @@ export function getComponents() {
}
return false;
}),
})
);
}
@ -65,7 +65,7 @@ export function camelize(str: string): string {
export function pascalize(str: string): string {
return camelize(str).replace(
pascalizeRE,
(_, c1, c2) => c1.toUpperCase() + c2,
(_, c1, c2) => c1.toUpperCase() + c2
);
}
@ -114,33 +114,13 @@ export function smartOutputFile(filePath: string, content: string) {
outputFileSync(filePath, content);
}
export async function mergeCustomViteConfig(
config: InlineConfig,
mode: 'production' | 'development',
): Promise<InlineConfig> {
export function mergeCustomViteConfig(config: InlineConfig) {
const vantConfig = getVantConfig();
const configureVite = vantConfig.build?.configureVite;
const userConfig = await loadConfigFromFile(
{
mode,
command: mode === 'development' ? 'serve' : 'build',
},
undefined,
process.cwd(),
);
if (configureVite) {
const ret = configureVite(config);
if (ret) {
config = ret;
}
return configureVite(config);
}
if (userConfig) {
return mergeConfig(config, userConfig.config);
}
return config;
}

View File

@ -1,6 +1,6 @@
import { createSpinner } from 'nanospinner';
import color from 'picocolors';
import { consola } from 'consola';
import consola from 'consola';
import { ROOT } from '../common/constant.js';
export function slimPath(path: string) {

View File

@ -1,4 +1,4 @@
import { execa } from 'execa';
import execa from 'execa';
import { consola } from './logger.js';
import { execSync } from 'child_process';
import { getVantConfig } from './constant.js';
@ -18,7 +18,7 @@ export function hasYarn() {
return hasYarnCache;
}
export function getPackageManager() {
function getPackageManager() {
const { build } = getVantConfig();
if (build?.packageManager) {

View File

@ -34,13 +34,8 @@ export async function compileBundles() {
getVantConfig().build?.bundleOptions || DEFAULT_OPTIONS;
await Promise.all(
bundleOptions.map(async (config) =>
build(
await mergeCustomViteConfig(
getViteConfigForPackage(config),
'production',
),
),
),
bundleOptions.map((config) =>
build(mergeCustomViteConfig(getViteConfigForPackage(config)))
)
);
}

View File

@ -1,6 +1,6 @@
import less from 'less';
import { join } from 'node:path';
import { readFileSync } from 'node:fs';
import { join } from 'path';
import { readFileSync } from 'fs';
import { CWD } from '../common/constant.js';
export async function compileLess(filePath: string) {

View File

@ -1,4 +1,4 @@
import { createRequire } from 'node:module';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);

View File

@ -1,7 +1,7 @@
import fse from 'fs-extra';
import babel from '@babel/core';
import esbuild, { type Format } from 'esbuild';
import { sep } from 'node:path';
import { sep } from 'path';
import { isJsx, replaceExt, getVantConfig } from '../common/index.js';
import { replaceCSSImportExt } from '../common/css.js';
import { replaceScriptImportExt } from './get-deps.js';
@ -10,7 +10,7 @@ const { readFileSync, removeSync, outputFileSync } = fse;
export async function compileScript(
filePath: string,
format: Format,
format: Format
): Promise<void> {
if (filePath.includes('.d.ts')) {
return;

View File

@ -1,5 +1,5 @@
import fse from 'fs-extra';
import path from 'node:path';
import path from 'path';
import hash from 'hash-sum';
import {
parse,
@ -127,7 +127,7 @@ export async function compileSfc(filePath: string): Promise<any> {
}
outputFile(scriptFilePath, script).then(resolve);
}),
})
);
}
@ -150,7 +150,7 @@ export async function compileSfc(filePath: string): Promise<any> {
// }
return outputFile(cssFilePath, styleSource);
}),
})
);
return Promise.all(tasks);

View File

@ -1,5 +1,5 @@
import color from 'picocolors';
import { createRequire } from 'node:module';
import { createRequire } from 'module';
import { createServer, build } from 'vite';
import {
getViteConfigForSiteDev,
@ -29,18 +29,12 @@ export function genSiteEntry(): Promise<void> {
export async function compileSite(production = false) {
await genSiteEntry();
if (production) {
const config = await mergeCustomViteConfig(
getViteConfigForSiteProd(),
'production',
);
const config = mergeCustomViteConfig(getViteConfigForSiteProd());
await build(config);
} else {
const config = await mergeCustomViteConfig(
getViteConfigForSiteDev(),
'development',
);
const config = mergeCustomViteConfig(getViteConfigForSiteDev());
const server = await createServer(config);
await server.listen(config.server?.port);
await server.listen();
const require = createRequire(import.meta.url);
const { version } = require('vite/package.json');

View File

@ -1,4 +1,4 @@
import { parse } from 'node:path';
import { parse } from 'path';
import fse from 'fs-extra';
import { getVantConfig, replaceExt } from '../common/index.js';
import { compileCss } from './compile-css.js';

View File

@ -3,8 +3,8 @@
*/
import fse from 'fs-extra';
import { createRequire } from 'node:module';
import { sep, join, relative } from 'node:path';
import { createRequire } from 'module';
import { sep, join, relative } from 'path';
import { getComponents, replaceExt } from '../common/index.js';
import { CSS_LANG, getCssBaseFile } from '../common/css.js';
import { checkStyleExists } from './gen-style-deps-map.js';
@ -81,7 +81,7 @@ function genEntry(params: {
}
export function genComponentStyle(
options: { cache: boolean } = { cache: true },
options: { cache: boolean } = { cache: true }
) {
if (!options.cache) {
const require = createRequire(import.meta.url);

View File

@ -1,4 +1,4 @@
import { join } from 'node:path';
import { join } from 'path';
import {
pascalize,
getComponents,
@ -20,7 +20,7 @@ function getPathByName(name: string, pathResolver?: PathResolver) {
function genImports(
names: string[],
pathResolver?: PathResolver,
namedExport?: boolean,
namedExport?: boolean
): string {
return names
.map((name) => {
@ -36,7 +36,7 @@ function genImports(
function genExports(
names: string[],
pathResolver?: PathResolver,
namedExport?: boolean,
namedExport?: boolean
): string {
if (namedExport) {
const exports = names

View File

@ -1,6 +1,6 @@
import { join } from 'node:path';
import { existsSync } from 'node:fs';
import { createRequire } from 'node:module';
import { join } from 'path';
import { existsSync } from 'fs';
import { createRequire } from 'module';
import { smartOutputFile, normalizePath } from '../common/index.js';
import { CSS_LANG, getCssBaseFile } from '../common/css.js';
import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant.js';

View File

@ -1,7 +1,12 @@
import glob from 'fast-glob';
import { join, parse } from 'node:path';
import { existsSync, readFileSync, readdirSync } from 'node:fs';
import { pascalize, getVantConfig, normalizePath } from '../common/index.js';
import { join, parse } from 'path';
import { existsSync, readFileSync, readdirSync } from 'fs';
import {
isDev,
pascalize,
getVantConfig,
normalizePath,
} from '../common/index.js';
import {
SRC_DIR,
DOCS_DIR,
@ -75,7 +80,10 @@ function genImportDocuments(items: DocumentItem[]) {
return items
.map((item) => {
const path = normalizePath(item.path);
return `const ${item.name} = () => import('${path}');`;
if (isDev()) {
return `const ${item.name} = () => import('${path}');`;
}
return `import ${item.name} from '${path}';`;
})
.join('\n');
}

View File

@ -1,5 +1,5 @@
import { join } from 'node:path';
import { existsSync, readdirSync } from 'node:fs';
import { join } from 'path';
import { existsSync, readdirSync } from 'fs';
import { SRC_DIR } from '../common/constant.js';
import {
pascalize,
@ -38,7 +38,7 @@ function genConfig(demos: DemoItem[]) {
function demoFilter(nav: any[]) {
return nav.filter((group) => {
group.items = group.items.filter((item: any) =>
demoNames.includes(item.path),
demoNames.includes(item.path)
);
return group.items.length;
});

View File

@ -1,6 +1,6 @@
import { relative, sep, join } from 'node:path';
import { relative, sep, join } from 'path';
import { CSS_LANG } from '../common/css.js';
import { existsSync } from 'node:fs';
import { existsSync } from 'fs';
import { getDeps, clearDepsCache, fillExt } from './get-deps.js';
import { getComponents, smartOutputFile } from '../common/index.js';
import { SRC_DIR, STYLE_DEPS_JSON_FILE } from '../common/constant.js';
@ -106,13 +106,13 @@ export async function genStyleDepsMap() {
Object.keys(map).forEach((key) => {
map[key] = map[key].sort(
(a, b) => sequence.indexOf(a) - sequence.indexOf(b),
(a, b) => sequence.indexOf(a) - sequence.indexOf(b)
);
});
smartOutputFile(
STYLE_DEPS_JSON_FILE,
JSON.stringify({ map, sequence }, null, 2),
JSON.stringify({ map, sequence }, null, 2)
);
resolve();

View File

@ -1,6 +1,6 @@
import { join } from 'node:path';
import { join } from 'path';
import { SCRIPT_EXTS, STYLE_EXTS } from '../common/constant.js';
import { readFileSync, existsSync } from 'node:fs';
import { readFileSync, existsSync } from 'fs';
let depsMap: Record<string, string[]> = {};
let existsCache: Record<string, boolean> = {};
@ -8,9 +8,6 @@ let existsCache: Record<string, boolean> = {};
// https://regexr.com/47jlq
const IMPORT_RE =
/import\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
const IMPORT_NOF_RE = /import\s*\(\s*?['"].+?['"]\)/g;
const EXPORT_FROM_RE =
/@?export\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
@ -19,11 +16,6 @@ function matchImports(code: string): string[] {
return imports.filter((line) => !line.includes('import type'));
}
function matchImportsNof(code: string): string[] {
const imports = code.match(IMPORT_NOF_RE) || [];
return imports.filter((line) => !line.includes('import type'));
}
function matchExportFroms(code: string): string[] {
const exportFroms = code.match(EXPORT_FROM_RE) || [];
return exportFroms.filter((line) => !line.includes('export type'));
@ -105,23 +97,17 @@ export function getDeps(filePath: string) {
/**
* 1. Replace .vue extension
* @example "import App from 'App.vue';" => "import App from 'App.xxx';"
* @example "defineAsyncComponent(() => import('../xxx.vue'))" => "defineAsyncComponent(() => import('../xxx.xxx'));"
*
* 2. if using .mjs or .cjs, complete the import path
* @example import './foo' -> import './foo.mjs'
* @example import './foo' -> import './foo/index.mjs'
* @example "defineAsyncComponent(() => import('../foo.vue'))" => "defineAsyncComponent(() => import('../foo.mjs'));"
*/
export function replaceScriptImportExt(
code: string,
filePath: string,
ext: string,
ext: string
) {
const imports = [
...matchImports(code),
...matchImportsNof(code),
...matchExportFroms(code),
];
const imports = [...matchImports(code), ...matchExportFroms(code)];
const updateImport = (index: number, newImport: string) => {
code = code.replace(imports[index], newImport);
@ -141,11 +127,6 @@ export function replaceScriptImportExt(
return;
}
const isExistExt = line.includes(ext);
if (isExistExt) {
return;
}
const pathInfo = getPathByImport(line, filePath);
if (pathInfo) {
@ -154,7 +135,7 @@ export function replaceScriptImportExt(
if (pathInfo.isIndex) {
const newLine = line.replace(
relativePath,
`${relativePath}/index${ext}`,
`${relativePath}/index${ext}`
);
updateImport(index, newLine);

View File

@ -0,0 +1,14 @@
import { Plugin } from 'release-it';
import { execSync } from 'child_process';
class VantCliReleasePlugin extends Plugin {
async beforeRelease() {
// log an empty line
console.log('');
execSync('vant-cli build', { stdio: 'inherit' });
execSync('vant-cli changelog', { stdio: 'inherit' });
}
}
export default VantCliReleasePlugin;

View File

@ -1,6 +1,11 @@
/* eslint-disable no-continue */
import { Articles } from './parser.js';
import { formatType, removeVersion, toKebabCase } from './utils.js';
import {
formatOptions,
formatType,
removeVersion,
toKebabCase,
} from './utils.js';
import { VueEventArgument, VueTag } from './type.js';
function formatComponentName(name: string, tagPrefix: string) {
@ -29,15 +34,9 @@ function formatArguments(input: string): VueEventArgument[] {
} else if ([':', ',', '_', ' '].includes(input[0])) {
input = input.substring(1);
} else {
const matched = input.match(/( |'|\||\w)+/);
if (matched?.length && matched[0]) {
const val = matched[0];
input = input.substring(val.length);
items.push(val);
} else {
input = '';
}
const val = input.match(/( |'|\||\w)+/)![0] || '';
input = input.substring(val.length);
items.push(val);
}
}
@ -67,6 +66,9 @@ function findTag(vueTags: VueTag[], name: string) {
const newTag: VueTag = {
name,
slots: [],
events: [],
attributes: [],
};
vueTags.push(newTag);
@ -77,7 +79,7 @@ function findTag(vueTags: VueTag[], name: string) {
export function formatter(
vueTags: VueTag[],
articles: Articles,
tagPrefix = '',
tagPrefix = ''
) {
if (!articles.length) {
return;
@ -105,16 +107,12 @@ export function formatter(
const tag = findTag(vueTags, name);
table.body.forEach((line) => {
const [name, desc, type, defaultVal] = line;
if (!tag.attributes) {
tag.attributes = [];
}
tag.attributes.push({
const [name, desc, type, defaultVal, options] = line;
tag.attributes!.push({
name: removeVersion(name),
default: defaultVal,
description: desc,
options: formatOptions(options),
value: {
type: formatType(type),
kind: 'expression',
@ -130,12 +128,7 @@ export function formatter(
table.body.forEach((line) => {
const [name, desc, args] = line;
if (!tag.events) {
tag.events = [];
}
tag.events.push({
tag.events!.push({
name: removeVersion(name),
description: desc,
arguments: formatArguments(args),
@ -150,12 +143,7 @@ export function formatter(
table.body.forEach((line) => {
const [name, desc] = line;
if (!tag.slots) {
tag.slots = [];
}
tag.slots.push({
tag.slots!.push({
name: removeVersion(name),
description: desc,
});

View File

@ -1,5 +1,5 @@
import glob from 'fast-glob';
import { join } from 'node:path';
import { join } from 'path';
import fse from 'fs-extra';
import { mdParser } from './parser.js';
import { formatter } from './formatter.js';
@ -36,7 +36,7 @@ export async function parseAndWrite(options: Options) {
const webTypes = genWebTypes(vueTags, options);
fse.outputFileSync(
join(options.outputDir, 'web-types.json'),
JSON.stringify(webTypes),
JSON.stringify(webTypes, null, 2)
);
}

View File

@ -1,4 +1,4 @@
import { PathLike } from 'node:fs';
import { PathLike } from 'fs';
export type VueSlot = {
name: string;
@ -20,6 +20,7 @@ export type VueAttribute = {
name: string;
default: string;
description: string;
options: string[];
value: {
kind: 'expression';
type: string;

View File

@ -2,7 +2,7 @@
export function toKebabCase(input: string): string {
return input.replace(
/[A-Z]/g,
(val, index) => (index === 0 ? '' : '-') + val.toLowerCase(),
(val, index) => (index === 0 ? '' : '-') + val.toLowerCase()
);
}
@ -20,3 +20,9 @@ export function formatType(type: string) {
export function normalizePath(path: string): string {
return path.replace(/\\/g, '/');
}
// `default` `primary` -> ['default', 'primary']
export function formatOptions(options?: string) {
if (!options) return [];
return options.replace(/`/g, '').split(' ');
}

View File

@ -12,8 +12,8 @@ export function genWebTypes(tags: VueTag[], options: Options) {
html: {
tags,
attributes: [],
'types-syntax': 'typescript',
},
},
'js-types-syntax': 'typescript',
};
}

View File

@ -1,4 +1,4 @@
import { join } from 'node:path';
import { join } from 'path';
import { setBuildTarget } from '../common/index.js';
import { CWD, ES_DIR, getVantConfig, LIB_DIR } from '../common/constant.js';
import type { InlineConfig } from 'vite';
@ -28,8 +28,6 @@ export function getViteConfigForPackage({
: undefined,
build: {
emptyOutDir: false,
lib: {
name,
entry,

View File

@ -1,12 +1,12 @@
import { join } from 'node:path';
import { createRequire } from 'node:module';
import { join } from 'path';
import { createRequire } from 'module';
import hljs from 'highlight.js';
import vitePluginMd from 'vite-plugin-md';
import vitePluginVue from '@vitejs/plugin-vue';
import vitePluginJsx from '@vitejs/plugin-vue-jsx';
import { setBuildTarget, getVantConfig, isDev } from '../common/index.js';
import { SITE_DIST_DIR, SITE_SRC_DIR } from '../common/constant.js';
import lodash from 'lodash';
import { injectHtml } from 'vite-plugin-html';
import type { InlineConfig, PluginOption } from 'vite';
import type MarkdownIt from 'markdown-it';
import { genSiteMobileShared } from '../compiler/gen-site-mobile-shared.js';
@ -131,18 +131,6 @@ function vitePluginGenVantBaseCode(): PluginOption {
};
}
function vitePluginHTML(data: object): PluginOption {
return {
name: 'vite-plugin-html',
transformIndexHtml: {
enforce: 'pre',
transform(html) {
return lodash.template(html)(data);
},
},
};
}
export function getViteConfigForSiteDev(): InlineConfig {
setBuildTarget('site');
@ -156,11 +144,6 @@ export function getViteConfigForSiteDev(): InlineConfig {
return {
root: SITE_SRC_DIR,
optimizeDeps: {
// https://github.com/youzan/vant/issues/10930
include: ['vue', 'vue-router'],
},
plugins: [
vitePluginGenVantBaseCode(),
vitePluginVue({
@ -189,16 +172,18 @@ export function getViteConfigForSiteDev(): InlineConfig {
},
}),
vitePluginJsx(),
vitePluginHTML({
...siteConfig,
title,
// `description` is used by the HTML ejs template,
// so it needs to be written explicitly here to avoid error: description is not defined
description: siteConfig.description,
headHtml,
baiduAnalytics,
enableVConsole,
meta: getHTMLMeta(vantConfig),
injectHtml({
data: {
...siteConfig,
title,
// `description` is used by the HTML ejs template,
// so it needs to be written explicitly here to avoid error: description is not defined
description: siteConfig.description,
headHtml,
baiduAnalytics,
enableVConsole,
meta: getHTMLMeta(vantConfig),
},
}),
],

View File

@ -1,6 +1,6 @@
// @ts-ignore
import fs from 'node:fs';
import { URL, fileURLToPath } from 'node:url';
import fs from 'fs';
import { URL, fileURLToPath } from 'url';
const packagePath = fileURLToPath(new URL('../package.json', import.meta.url));
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));

View File

@ -1,3 +1,6 @@
// some modules with missing type definitions
declare module 'execa';
declare module 'hash-sum';
declare module '@babel/core';
declare module 'release-it';
declare module 'conventional-changelog';

View File

@ -0,0 +1,35 @@
-{{#if scope}} {{scope}}:
{{~/if}} {{#if subject}}
{{~subject}}
{{~else}}
{{~header}}
{{~/if}}
{{#if references~}}
{{~#each references}} [{{~this.repository}}#{{this.issue}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}
/{{~@root.issue}}/{{this.issue}}){{/each}}
{{~else}} [{{shortHash}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}
/{{~@root.commit}}/{{hash}})
{{~/if}}

View File

@ -0,0 +1,15 @@
### [v{{version}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}
/compare/{{previousTag}}...{{currentTag}})
`{{date}}`

View File

@ -0,0 +1,12 @@
{{> header}}
{{#each commitGroups}}
{{#if title}}
**{{title}}**
{{/if}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}
{{/each}}
{{> footer}}

Some files were not shown because too many files have changed in this diff Show More