UNPKG

@142vip/changelog

Version:

基于Git提交信息,生成变更记录,输出Markdown格式的日志文件

77 lines (71 loc) 2.72 kB
'use strict'; const changelog_api = require('./shared/changelog.7Ncn4daK.cjs'); const utils = require('@142vip/utils'); require('@142vip/changelog'); require('ofetch'); const CONFIG_DEFAULT_NAME = "changelog"; const CONFIG_DEFAULT_HEADER = `# Changelog All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. `; const ChangelogDefaultConfig = { scopeMap: {}, header: CONFIG_DEFAULT_HEADER, types: { feat: { title: "\u2728 Features", semver: "minor" }, perf: { title: "\u{1F525} Performance", semver: "patch" }, fix: { title: "\u{1F41B} Bug Fixes", semver: "patch" }, refactor: { title: "\u{1F485} Refactors", semver: "patch" }, docs: { title: "\u{1F4D6} Documentation", semver: "patch" }, build: { title: "\u{1F4E6} Build", semver: "patch" }, types: { title: "\u{1F30A} Types", semver: "patch" }, release: { title: "\u{1F60F} Release Packages", semver: "patch" } }, titles: { breakingChanges: "\u{1F6A8} Breaking Changes" }, contributors: true, capitalize: true, group: true, emoji: true, baseUrl: "github.com", baseUrlApi: "api.github.com", prerelease: true }; function defineChangelogConfig(config) { return config; } function loadChangelogConfig() { return utils.vipConfig.loadCliConfig(CONFIG_DEFAULT_NAME, ChangelogDefaultConfig); } function parseCliOptions(cliOptions) { const changelogConfig = loadChangelogConfig(); const config = utils.vipConfig.mergeCommanderConfig(changelogConfig, cliOptions); if (config.to == null) { config.to = utils.VipGit.getTagInHead() ?? utils.VipGit.getCurrentBranch(); } if (config.name == null) { config.name = config.to; } if (config.from == null) { config.from = utils.VipGit.getLastMatchingTag(config.to) || utils.VipGit.getRecentCommitHash(); } if (config.repo == null) { config.repo = utils.VipGit.getGitHubRepo(config.baseUrl); } if (config.prerelease == null) { config.prerelease = utils.VipGit.isPrerelease(config.to); } config.scopeName = cliOptions.scopeName; return config; } exports.ChangelogAPI = changelog_api.ChangelogAPI; exports.GitCommitAPI = changelog_api.GitCommitAPI; exports.GitCommitMessageType = changelog_api.GitCommitMessageType; exports.GithubAPI = changelog_api.GithubAPI; exports.MarkdownAPI = changelog_api.MarkdownAPI; exports.CONFIG_DEFAULT_HEADER = CONFIG_DEFAULT_HEADER; exports.CONFIG_DEFAULT_NAME = CONFIG_DEFAULT_NAME; exports.ChangelogDefaultConfig = ChangelogDefaultConfig; exports.defineChangelogConfig = defineChangelogConfig; exports.loadChangelogConfig = loadChangelogConfig; exports.parseCliOptions = parseCliOptions;