mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
refactor(cli): use GitHub changelog instead of conventional-changelog (#12139)
* refactor(cli): use GitHub changelog instead of conventional-changelog * chore: revert lock file
This commit is contained in:
parent
8b3ee8723b
commit
cac08f88e8
@ -1 +0,0 @@
|
|||||||
**/template/*.hbs
|
|
@ -48,11 +48,7 @@ Build documentation website. Files will be output to `site` directory.
|
|||||||
|
|
||||||
### release
|
### release
|
||||||
|
|
||||||
Publish to npm. `build` and `changelog` will be automatically execute when run `release`.
|
Publish to npm. `build` will be automatically execute when run `release`.
|
||||||
|
|
||||||
### changelog
|
|
||||||
|
|
||||||
Generate changelog based on commit records.
|
|
||||||
|
|
||||||
### commit-lint
|
### commit-lint
|
||||||
|
|
||||||
|
@ -50,11 +50,7 @@ npx vant-cli dev
|
|||||||
|
|
||||||
### release
|
### release
|
||||||
|
|
||||||
发布组件库,发布前会自动执行 build 和 changelog 命令,并按照流程发布 npm 包。
|
发布组件库,发布前会自动执行 build 命令,并按照流程发布 npm 包。
|
||||||
|
|
||||||
### changelog
|
|
||||||
|
|
||||||
基于 commit 记录生成更新日志,基于 [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) 实现。
|
|
||||||
|
|
||||||
### commit-lint
|
### commit-lint
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
"lib",
|
"lib",
|
||||||
"cjs",
|
"cjs",
|
||||||
"site",
|
"site",
|
||||||
"template",
|
|
||||||
"bin.js"
|
"bin.js"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -59,7 +58,6 @@
|
|||||||
"autoprefixer": "^10.4.8",
|
"autoprefixer": "^10.4.8",
|
||||||
"commander": "^10.0.0",
|
"commander": "^10.0.0",
|
||||||
"consola": "^3.0.2",
|
"consola": "^3.0.2",
|
||||||
"conventional-changelog": "^3.1.25",
|
|
||||||
"esbuild": "^0.18.11",
|
"esbuild": "^0.18.11",
|
||||||
"eslint": "^8.31.0",
|
"eslint": "^8.31.0",
|
||||||
"execa": "^6.1.0",
|
"execa": "^6.1.0",
|
||||||
|
@ -89,14 +89,6 @@ program
|
|||||||
return buildSite();
|
return buildSite();
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
|
||||||
.command('changelog')
|
|
||||||
.description('Generate changelog')
|
|
||||||
.action(async () => {
|
|
||||||
const { changelog } = await import('./commands/changelog.js');
|
|
||||||
return changelog();
|
|
||||||
});
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('commit-lint <gitParams>')
|
.command('commit-lint <gitParams>')
|
||||||
.description('Lint commit message')
|
.description('Lint commit message')
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
import { join, dirname } from 'node:path';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
import { ROOT } from '../common/constant.js';
|
|
||||||
import { createSpinner, slimPath } from '../common/logger.js';
|
|
||||||
import { createWriteStream, readFileSync } from 'node: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();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@ -61,10 +61,6 @@ function buildPackage(packageManager: string) {
|
|||||||
execSync(command, { stdio: 'inherit' });
|
execSync(command, { stdio: 'inherit' });
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateChangelog() {
|
|
||||||
execSync('vant-cli changelog', { stdio: 'inherit' });
|
|
||||||
}
|
|
||||||
|
|
||||||
function publishPackage(packageManager: string, tag: string) {
|
function publishPackage(packageManager: string, tag: string) {
|
||||||
let command = `${packageManager} publish --tag ${tag}`;
|
let command = `${packageManager} publish --tag ${tag}`;
|
||||||
|
|
||||||
@ -109,7 +105,6 @@ export async function release(command: { tag?: string; gitTag?: boolean }) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
buildPackage(packageManager);
|
buildPackage(packageManager);
|
||||||
generateChangelog();
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
consola.error('Failed to build package, rollback to the previous version.');
|
consola.error('Failed to build package, rollback to the previous version.');
|
||||||
setPkgVersion(currentVersion, cwd);
|
setPkgVersion(currentVersion, cwd);
|
||||||
|
1
packages/vant-cli/src/module.d.ts
vendored
1
packages/vant-cli/src/module.d.ts
vendored
@ -1,4 +1,3 @@
|
|||||||
// some modules with missing type definitions
|
// some modules with missing type definitions
|
||||||
declare module 'hash-sum';
|
declare module 'hash-sum';
|
||||||
declare module '@babel/core';
|
declare module '@babel/core';
|
||||||
declare module 'conventional-changelog';
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
-{{#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}}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
### [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}}`
|
|
@ -1,12 +0,0 @@
|
|||||||
{{> header}}
|
|
||||||
{{#each commitGroups}}
|
|
||||||
|
|
||||||
{{#if title}}
|
|
||||||
**{{title}}**
|
|
||||||
|
|
||||||
{{/if}}
|
|
||||||
{{#each commits}}
|
|
||||||
{{> commit root=@root}}
|
|
||||||
{{/each}}
|
|
||||||
{{/each}}
|
|
||||||
{{> footer}}
|
|
716
pnpm-lock.yaml
generated
716
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user