Compare commits

..

No commits in common. "ad6514f43d2862819e5dc4abb97a8f69fceed6d7" and "49e1e9f73ebb781bf8d305b2d9870a7b5905aaa9" have entirely different histories.

32 changed files with 1723 additions and 315 deletions

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

@ -11,13 +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 changelogs.
请参阅 [CHANGELOG](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.

3
.gitignore vendored
View File

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

View File

@ -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": [
@ -32,6 +32,7 @@
"license": "MIT",
"devDependencies": {
"@types/fs-extra": "^11.0.1",
"release-it": "^16.1.3",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
@ -41,5 +42,11 @@
"fs-extra": "^11.1.0",
"enquirer": "2.3.6",
"picocolors": "^1.0.0"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: create-vant-cli-app v${version}"
}
}
}

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@vant/area-data",
"version": "1.5.0",
"version": "1.4.1",
"description": "Vant 省市区数据",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
@ -21,7 +21,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": {
@ -38,7 +38,14 @@
"license": "MIT",
"devDependencies": {
"esbuild": "^0.18.11",
"release-it": "^16.1.3",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/area-data v${version}"
}
}
}

View File

@ -1391,10 +1391,11 @@ export const areaList: {
340190: '高新技术开发区',
340191: '经济技术开发区',
340202: '镜湖区',
340203: '弋江区',
340207: '鸠江区',
340209: '弋江区',
340210: '湾沚区',
340212: '繁昌区',
340208: '三山区',
340221: '芜湖县',
340222: '繁昌县',
340223: '南陵县',
340281: '无为市',
340302: '龙子湖区',

View File

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

View File

@ -1,21 +1,12 @@
# 更新日志
## 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
- 升级 esbuild 0.17
- 升级 vite 4.2
- 优化 tsc 错误日志的格式
## v6.0.1

View File

@ -50,7 +50,7 @@ npx vant-cli dev
### release
发布组件库,发布前会自动执行 build 和 changelog 命令,并按照流程发布 npm 包。
发布组件库,发布前会自动执行 build 和 changelog 命令,并通过 [release-it](https://github.com/release-it/release-it) 发布 npm 包。
### changelog

View File

@ -1,6 +1,6 @@
{
"name": "@vant/cli",
"version": "6.2.0",
"version": "6.1.0",
"type": "module",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
@ -13,7 +13,7 @@
"scripts": {
"dev": "tsc --watch",
"build": "rimraf ./lib && tsc",
"release": "vant-cli release",
"release": "pnpm build & release-it",
"prepare": "pnpm build"
},
"files": [
@ -63,7 +63,6 @@
"esbuild": "^0.18.11",
"eslint": "^8.31.0",
"execa": "^6.1.0",
"enquirer": "2.3.6",
"fast-glob": "^3.2.11",
"fs-extra": "^11.1.0",
"hash-sum": "^2.0.0",
@ -83,11 +82,18 @@
"postcss": "^8.4.23",
"postcss-load-config": "^4.0.1",
"prettier": "^3.0.0",
"release-it": "^16.1.3",
"terser": "^5.16.1",
"transliteration": "^2.3.5",
"typescript": "^5.0.4",
"vite": "^4.4.2",
"vite-plugin-md": "^0.11.9",
"vue-router": "^4.1.6"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/cli v${version}"
}
}
}

View File

@ -75,7 +75,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);

View File

@ -1,122 +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 'node:path';
import { fileURLToPath } from 'node: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 generateChangelog() {
execSync('vant-cli changelog', { 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);
generateChangelog();
} 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

@ -18,7 +18,7 @@ export function hasYarn() {
return hasYarnCache;
}
export function getPackageManager() {
function getPackageManager() {
const { build } = getVantConfig();
if (build?.packageManager) {

View File

@ -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,
) {
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);

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,4 +1,5 @@
// some modules with missing type definitions
declare module 'hash-sum';
declare module '@babel/core';
declare module 'release-it';
declare module 'conventional-changelog';

View File

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

View File

@ -25,7 +25,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"
},
"repository": {
"type": "git",
@ -40,7 +40,14 @@
"vant": "workspace:*",
"vue": "^3.3.4",
"esbuild": "^0.18.11",
"release-it": "^16.1.3",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/compat v${version}"
}
}
}

View File

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

View File

@ -8,7 +8,6 @@
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"release": "vant-cli release",
"update:deps": "pnpm update --latest --interactive"
},
"repository": {

View File

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

View File

@ -8,7 +8,7 @@
"src"
],
"scripts": {
"release": "vant-cli release"
"release": "release-it"
},
"publishConfig": {
"access": "public",
@ -21,5 +21,16 @@
},
"bugs": "https://github.com/vant-ui/vant/issues",
"author": "chenjiahan",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"release-it": "^16.1.3"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/icons v${version}",
"addUntrackedFiles": true,
"requireCleanWorkingDir": false
}
}
}

View File

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

View File

@ -25,7 +25,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"
},
"repository": {
@ -39,7 +39,14 @@
"devDependencies": {
"@popperjs/core": "^2.11.6",
"esbuild": "^0.18.11",
"release-it": "^16.1.3",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/popperjs v${version}"
}
}
}

View File

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

View File

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

View File

@ -22,7 +22,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": {
@ -39,11 +39,18 @@
"license": "MIT",
"devDependencies": {
"esbuild": "^0.18.11",
"release-it": "^16.1.3",
"rimraf": "^5.0.0",
"typescript": "^5.0.4",
"vue": "^3.3.4"
},
"peerDependencies": {
"vue": "^3.0.0"
},
"release-it": {
"git": {
"tag": false,
"commitMessage": "release: @vant/use v${version}"
}
}
}

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "vant",
"version": "4.6.4-beta.2",
"version": "4.6.3",
"description": "Mobile UI Components built on Vue",
"main": "lib/vant.cjs.js",
"module": "es/index.mjs",
@ -18,7 +18,7 @@
"test": "vant-cli test",
"build": "vant-cli build",
"build:site": "vant-cli build-site",
"release": "cp ../../README.md ./ && vant-cli release --gitTag && rm ./README.md",
"release": "cp ../../README.md ./ && vant-cli release && rm ./README.md",
"release:site": "pnpm build:site && npx gh-pages -d site-dist --add",
"test:update": "vant-cli test --updateSnapshot",
"test:watch": "vant-cli test --watch",
@ -70,5 +70,10 @@
"lib/**/style/*",
"*.css"
],
"release-it": {
"git": {
"commitMessage": "release: vant v${version}"
}
},
"web-types": "lib/web-types.json"
}

1669
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff