diff --git a/package.json b/package.json index 1a968e1c5..167415f14 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dev": "npm run build:entry && webpack-dev-server --config build/webpack.dev.js", "lint": "eslint ./src --ext .js,.vue,.ts,.tsx && stylelint \"src/**/*.less\" --fix", "build:entry": "node build/build-entry.js", - "build:changelog": "vant-doc changelog ./docs/markdown/changelog.generated.md --tag 2.0.0", + "build:changelog": "vant changelog ./docs/markdown/changelog.generated.md --tag 2.0.0", "build:lib": "node build/build-lib.js", "test": "jest", "test:watch": "jest --watch", @@ -70,6 +70,7 @@ "@babel/preset-env": "^7.5.5", "@babel/preset-typescript": "^7.3.3", "@types/jest": "^24.0.16", + "@vant/cli": "^0.1.1", "@vant/doc": "^2.4.0", "@vant/eslint-config": "^1.2.4", "@vant/markdown-loader": "^2.2.0", diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json new file mode 100644 index 000000000..71faa9427 --- /dev/null +++ b/packages/vant-cli/package.json @@ -0,0 +1,18 @@ +{ + "name": "@vant/cli", + "version": "0.1.1", + "description": "vant cli tools", + "main": "./src/index.js", + "bin": { + "vant": "./src/index.js" + }, + "publishConfig": { + "access": "public" + }, + "license": "MIT", + "repository": "https://github.com/youzan/vant/tree/dev/packages/vant-cli", + "dependencies": { + "commander": "^2.17.1", + "shelljs": "^0.8.2" + } +} diff --git a/packages/vant-cli/src/changelog.js b/packages/vant-cli/src/changelog.js new file mode 100644 index 000000000..431bf0bb8 --- /dev/null +++ b/packages/vant-cli/src/changelog.js @@ -0,0 +1,25 @@ +const path = require('path'); +const shelljs = require('shelljs'); + +function changelog(dist, cmd) { + const basepath = process.cwd(); + const tag = cmd.tag || 'v1.0.0'; + + shelljs.exec(` + basepath=${basepath} + + github_changelog_generator \ + --header-label "# 更新日志" \ + --bugs-label "**Bug Fixes**" \ + --enhancement-label "**Breaking changes**" \ + --issues-label "**Issue**" \ + --pr-label "**Improvements**" \ + --no-issues \ + --no-unreleased \ + --since-tag ${tag} \ + -o ${path.join(basepath, dist)} + ` + ); +} + +module.exports = changelog; diff --git a/packages/vant-cli/src/index.js b/packages/vant-cli/src/index.js new file mode 100644 index 000000000..0fd9b3ab9 --- /dev/null +++ b/packages/vant-cli/src/index.js @@ -0,0 +1,11 @@ +#!/usr/bin/env node + +const commander = require('commander'); +const changelog = require('./changelog'); + +commander + .command('changelog