forked from 3lang3/react-vant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
321 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ es | |
lib | ||
site | ||
dist | ||
changelog.generated.md | ||
|
||
# log file | ||
.changelog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*hbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { join } from 'path'; | ||
import conventionalChangelog from 'conventional-changelog'; | ||
import { createWriteStream, readFileSync } from 'fs-extra'; | ||
import { ROOT } from '../common/constant'; | ||
import { ora, slimPath } from '../common/logger'; | ||
|
||
const DIST_FILE = join(ROOT, './changelog.generated.md'); | ||
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 = ora('Generating changelog...').start(); | ||
|
||
return new Promise((resolve) => { | ||
conventionalChangelog( | ||
{ | ||
preset: 'angular', | ||
releaseCount: 2, | ||
}, | ||
{ | ||
mainTemplate, | ||
headerPartial, | ||
commitPartial, | ||
transform, | ||
}, | ||
) | ||
.pipe(createWriteStream(DIST_FILE)) | ||
.on('close', () => { | ||
spinner.succeed(`Changelog generated at ${slimPath(DIST_FILE)}`); | ||
resolve(); | ||
}); | ||
}); | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/react-vant-cli/src/compiler/vant-cli-release-plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-{{#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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### [v{{version}}]({{~@root.repoUrl}}/compare/{{previousTag}}...{{currentTag}}) `{{date}}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{> header}} | ||
{{#each commitGroups}} | ||
|
||
{{#if title}} | ||
**{{title}}** | ||
|
||
{{/if}} | ||
{{#each commits}} | ||
{{> commit root=@root}} | ||
{{/each}} | ||
{{/each}} | ||
{{> footer}} |
Oops, something went wrong.