mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-21 13:59:15 +08:00
chore(cli): add changelog template files
This commit is contained in:
parent
4377a1f3aa
commit
2299879dff
@ -19,10 +19,10 @@
|
||||
"test": "vant-cli test",
|
||||
"build": "vant-cli build",
|
||||
"release": "vant-cli release",
|
||||
"changelog": "vant-cli changelog",
|
||||
"test:watch": "vant-cli test --watch",
|
||||
"release:site": "sh docs/site/release.sh",
|
||||
"test:coverage": "open test/coverage/index.html",
|
||||
"changelog": "vant-cli changelog ./changelog.generated.md --tag 2.3.0"
|
||||
"test:coverage": "open test/coverage/index.html"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
@ -17,6 +17,7 @@
|
||||
"files": [
|
||||
"lib",
|
||||
"site",
|
||||
"template",
|
||||
"preset.js"
|
||||
],
|
||||
"author": "chenjiahan",
|
||||
|
@ -1,41 +1,18 @@
|
||||
import { join } from 'path';
|
||||
import { ROOT } from '../common/constant';
|
||||
import { logger } from '../common/logger';
|
||||
import { createWriteStream } from 'fs-extra';
|
||||
import { createWriteStream, readFileSync } from 'fs-extra';
|
||||
// @ts-ignore
|
||||
import conventionalChangelog from 'conventional-changelog';
|
||||
|
||||
const file = join(ROOT, './changelog.generated.md');
|
||||
const DIST_FILE = join(ROOT, './changelog.generated.md');
|
||||
const MAIN_TEMPLATE = join(__dirname, '../../template/changelog-main.hbs');
|
||||
const HEADER_TEMPALTE = join(__dirname, '../../template/changelog-header.hbs');
|
||||
const COMMIT_TEMPALTE = join(__dirname, '../../template/changelog-commit.hbs');
|
||||
|
||||
const mainTemplate = `{{> header}}
|
||||
|
||||
{{#each commitGroups}}
|
||||
|
||||
{{#if title}}
|
||||
**{{title}}**
|
||||
|
||||
{{/if}}
|
||||
{{#each commits}}
|
||||
{{> commit root=@root}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
{{> footer}}`;
|
||||
|
||||
const headerPartial = `### [v{{version}}]({{~@root.repoUrl}}/compare/{{previousTag}}...{{currentTag}})
|
||||
\`{{date}}\``;
|
||||
|
||||
const commitPartial = `*{{#if scope}} {{scope}}:
|
||||
{{~/if}} {{#if subject}}
|
||||
{{~subject}}
|
||||
{{~else}}
|
||||
{{~header}}
|
||||
{{~/if}}
|
||||
{{#if references~}}
|
||||
{{~#each references}} [{{~this.repository}}#{{this.issue}}]({{~@root.repoUrl}}/{{~@root.issue}}/{{this.issue}}){{/each}}
|
||||
{{~else}} [{{shortHash}}]({{~@root.repoUrl}}/{{~@root.commit}}/{{hash}})
|
||||
{{~/if}}
|
||||
|
||||
`;
|
||||
const mainTemplate = readFileSync(MAIN_TEMPLATE, 'utf-8');
|
||||
const headerPartial = readFileSync(HEADER_TEMPALTE, 'utf-8');
|
||||
const commitPartial = readFileSync(COMMIT_TEMPALTE, 'utf-8');
|
||||
|
||||
function formatType(type: string) {
|
||||
const MAP: Record<string, string> = {
|
||||
@ -87,8 +64,8 @@ export function changelog() {
|
||||
transform
|
||||
}
|
||||
)
|
||||
.pipe(createWriteStream(file))
|
||||
.pipe(createWriteStream(DIST_FILE))
|
||||
.on('close', () => {
|
||||
logger.success(`Generated changelog at ${file}`);
|
||||
logger.success(`Generated changelog at ${DIST_FILE}`);
|
||||
});
|
||||
}
|
||||
|
@ -23,9 +23,7 @@ command('build')
|
||||
|
||||
command('release').action(release);
|
||||
|
||||
command('changelog <dir>')
|
||||
.option('--tag [tag]', 'Since tag')
|
||||
.action(changelog);
|
||||
command('changelog').action(changelog);
|
||||
|
||||
command('build-site').action(buildSite);
|
||||
|
||||
|
11
packages/vant-cli/template/changelog-commit.hbs
Normal file
11
packages/vant-cli/template/changelog-commit.hbs
Normal file
@ -0,0 +1,11 @@
|
||||
*{{#if scope}} {{scope}}:
|
||||
{{~/if}} {{#if subject}}
|
||||
{{~subject}}
|
||||
{{~else}}
|
||||
{{~header}}
|
||||
{{~/if}}
|
||||
{{#if references~}}
|
||||
{{~#each references}} [{{~this.repository}}#{{this.issue}}]({{~@root.repoUrl}}/{{~@root.issue}}/{{this.issue}}){{/each}}
|
||||
{{~else}} [{{shortHash}}]({{~@root.repoUrl}}/{{~@root.commit}}/{{hash}})
|
||||
{{~/if}}
|
||||
|
2
packages/vant-cli/template/changelog-header.hbs
Normal file
2
packages/vant-cli/template/changelog-header.hbs
Normal file
@ -0,0 +1,2 @@
|
||||
### [v{{version}}]({{~@root.repoUrl}}/compare/{{previousTag}}...{{currentTag}})
|
||||
`{{date}}`
|
12
packages/vant-cli/template/changelog-main.hbs
Normal file
12
packages/vant-cli/template/changelog-main.hbs
Normal file
@ -0,0 +1,12 @@
|
||||
{{> header}}
|
||||
{{#each commitGroups}}
|
||||
|
||||
{{#if title}}
|
||||
**{{title}}**
|
||||
|
||||
{{/if}}
|
||||
{{#each commits}}
|
||||
{{> commit root=@root}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
{{> footer}}
|
Loading…
x
Reference in New Issue
Block a user