UNPKG

@ruan-cat/commitlint-config

Version:
809 lines (800 loc) 27.6 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { changelogogenUseTypes: () => changelogogenUseTypes, commitTypes: () => commitTypes, commonScopes: () => commonScopes, config: () => config, convertCommitTypesToCzGitFormat: () => convertCommitTypesToCzGitFormat, createPackagescopes: () => createPackagescopes, defScopes: () => defScopes, default: () => index_default, getDefaultScope: () => getDefaultScope, getPackagesNameAndDescription: () => getPackagesNameAndDescription, getScopes: () => getScopes, getTypes: () => getTypes, getUserConfig: () => getUserConfig, parseGitStatusOutput: () => parseGitStatusOutput }); module.exports = __toCommonJS(index_exports); // src/commit-types.ts var commitTypes = [ { emoji: "\u2728", type: "feat", semver: "minor", description: "\u65B0\u589E\u529F\u80FD", longDescription: "A new feature" }, { emoji: "\u{1F41E}", type: "fix", semver: "patch", description: "\u4FEE\u590D\u7F3A\u9677", longDescription: "A bug fix" }, { emoji: "\u{1F4C3}", type: "docs", description: "\u6587\u6863\u66F4\u65B0", longDescription: "Documentation only changes" }, { emoji: "\u{1F4E6}", type: "deps", semver: "patch", description: "\u4F9D\u8D56\u66F4\u65B0" }, { emoji: "\u{1F9EA}", type: "test", description: "\u6D4B\u8BD5\u76F8\u5173", longDescription: "Adding missing tests or correcting existing tests" }, { emoji: "\u{1F528}", type: "build", semver: "patch", description: "\u6784\u5EFA\u76F8\u5173", longDescription: "Changes that affect the build system or external dependencies" }, { emoji: "\u{1F40E}", type: "ci", description: "\u6301\u7EED\u96C6\u6210", longDescription: "Changes to our CI configuration files and scripts" }, { emoji: "\u{1F4E2}", type: "publish", description: "\u53D1\u5E03\u4F9D\u8D56\u5305", longDescription: "\u4F9D\u8D56\u5305\u53D1\u5E03\u7248\u672C\u3002" }, { emoji: "\u{1F984}", type: "refactor", semver: "patch", description: "\u4EE3\u7801\u91CD\u6784", longDescription: "A code change that neither fixes a bug nor adds a feature" }, { emoji: "\u{1F388}", type: "perf", semver: "patch", description: "\u6027\u80FD\u63D0\u5347", longDescription: "A code change that improves performance" }, { emoji: "\u{1F389}", type: "init", semver: "patch", description: "\u521D\u59CB\u5316\u9879\u76EE", longDescription: "\u9879\u76EE\u521D\u59CB\u5316\u3002" }, { emoji: "\u{1F527}", type: "config", semver: "patch", description: "\u66F4\u65B0\u914D\u7F6E", longDescription: "\u914D\u7F6E\u66F4\u65B0\u3002\u901A\u7528\u6027\u7684\u914D\u7F6E\u66F4\u65B0\u3002" }, { emoji: "\u{1F433}", type: "chore", semver: "patch", description: "\u5176\u4ED6\u4FEE\u6539", longDescription: "Other changes that do not modify src or test files" }, { emoji: "\u{1F519}", type: "revert", description: "\u56DE\u9000\u4EE3\u7801", longDescription: "Revert to a commit" }, { emoji: "\u{1F52A}", type: "delete", description: "\u5220\u9664\u5783\u573E", longDescription: "\u5220\u9664\u65E0\u610F\u4E49\u7684\u4E1C\u897F\uFF0C\u6CE8\u91CA\uFF0C\u6587\u4EF6\uFF0C\u4EE3\u7801\u6BB5\u7B49\u3002" }, { emoji: "\u{1F310}", type: "i18n", description: "\u56FD\u9645\u5316", longDescription: "\u4E13\u95E8\u8BBE\u7F6E\u56FD\u9645\u5316\u7684\u7FFB\u8BD1\u6587\u672C\u3002" }, { emoji: "\u{1F308}", type: "style", description: "\u4EE3\u7801\u683C\u5F0F", longDescription: "Changes that do not affect the meaning of the code" }, { emoji: "\u{1F914}", type: "save-file", description: "\u4FDD\u5B58\u6587\u4EF6", longDescription: "\u4EC5\u4EC5\u662F\u4E3A\u4E86\u4FDD\u5B58\u6587\u4EF6\u3002" } // 暂不需要该提交类型。 // { // emoji: "✋", // type: "main-pull-update", // description: "主分支拉取更新", // longDescription: "主分支拉取更新。", // }, // { // emoji: "⏩", // type: "mark-progress", // description: "标记进度", // longDescription: "标记进度。", // }, ]; // src/common-scopes.ts var commonScopes = [ // 根目录 { code: "root", value: "root", desc: "\u6839\u76EE\u5F55", glob: [ // === 基础点配置文件 === ".gitignore", ".gitattributes", ".czrc", ".nvmrc", ".npmrc", ".editorconfig", // Prettier 配置 ".prettierrc", ".prettierrc.js", ".prettierrc.cjs", ".prettierrc.mjs", ".prettierrc.json", ".prettierrc.yaml", ".prettierrc.yml", ".prettierignore", // ESLint 配置(根目录的) ".eslintrc", ".eslintrc.js", ".eslintrc.cjs", ".eslintrc.json", ".eslintrc.yaml", ".eslintrc.yml", ".eslintignore", // === 文档文件 === "README", "README.md", "README.txt", "LICENSE", "LICENSE.md", "LICENSE.txt", "CHANGELOG", "CHANGELOG.md", "CONTRIBUTING", "CONTRIBUTING.md", "CODE_OF_CONDUCT", "CODE_OF_CONDUCT.md", "SECURITY", "SECURITY.md", // === 根目录脚本 === "*.sh", // Shell 脚本 "*.bat", // Windows 批处理 "*.ps1", // PowerShell 脚本 "*.cmd", // Windows 命令脚本 // === 其他常见根目录配置 === "Makefile", "Dockerfile", ".dockerignore" ] }, // 配置文件 { code: "config", value: "config", desc: "\u5404\u79CD\u914D\u7F6E\u6587\u4EF6", glob: [ "**/*.config.js", "**/*.config.ts", "**/*.config.cjs", "**/*.config.mjs", "**/*.config.json", ".config/**", "**/turbo.json" ] }, // 任务调度器 { code: "turbo", value: "turbo", desc: "\u4EFB\u52A1\u8C03\u5EA6\u5668", glob: ["**/turbo.json"] }, // 包配置 { code: "package.json", value: "package.json", desc: "\u5305\u914D\u7F6E", glob: ["**/package.json", "pnpm-workspace.yaml"] }, // vite打包工具配置 { code: "vite.config.js/ts", value: "vite", desc: "vite\u6253\u5305\u5DE5\u5177\u914D\u7F6E", glob: ["**/vite.config.js", "**/vite.config.ts"] }, // vitepress文档工具配置 { code: "vitepress", value: "vitepress", desc: "vitepress\u6587\u6863\u5DE5\u5177\u914D\u7F6E", glob: ["**/.vitepress/config.mts", "**/.vitepress/config.ts", "**/.vitepress/theme/index.ts"] }, // cz配置,即git提交工具的配置 { code: "commitlint.config.cjs", value: "commitlint", desc: "cz\u914D\u7F6E\uFF0C\u5373git\u63D0\u4EA4\u5DE5\u5177\u7684\u914D\u7F6E", glob: ["**/commitlint.config.cjs"] }, // typescript项目配置 { code: "tsconfig", value: "tsc", desc: "typescript\u9879\u76EE\u914D\u7F6E", glob: ["**/tsconfig*.json"] }, // server 服务端接口 { code: "server", value: "server", desc: "\u670D\u52A1\u7AEF\u63A5\u53E3", glob: ["**/server/**/*.ts", "**/servers/**/*.ts"] }, // 路由 { code: "router", value: "router", desc: "\u8DEF\u7531\u914D\u7F6E", glob: ["**/router/**/*.ts", "**/routers/**/*.ts"] }, // vscode配置 { code: "vscode/settings.json", value: "vsc", desc: "vscode\u914D\u7F6E", glob: ["**/.vscode/**"] }, // 国际化 { code: "i18n", value: "i18n", desc: "\u56FD\u9645\u5316" // TODO: 国际化配置的 glob 匹配路径。 需要先去看看 i18n 常见的路径配置才能得知。 // glob: ["**/i18n/**"], }, // 提示词 { code: "prompt", value: "prompt", desc: "\u63D0\u793A\u8BCD\u3002\u7279\u6307\u548CAI\u534F\u4F5C\u4F7F\u7528\u7684\u63D0\u793A\u8BCD\u6587\u4EF6\u3002", glob: ["**/prompts/**/*.md", ".github/prompts/**/*.md"] }, // API接口 { code: "api", value: "api", desc: "API\u63A5\u53E3" }, // openspec 提示词文档配置 { code: "openspec", value: "openspec", desc: "openspec\u63D0\u793A\u8BCD\u6587\u6863\u914D\u7F6E\u3002\u7279\u6307\u9AD8\u5F3A\u5EA6\u5728 openspec \u76EE\u5F55\u5185\u8FED\u4EE3\u66F4\u65B0\u7684\u4EFB\u52A1\u8BF4\u660E\u6587\u6863\u3002", glob: ["**/openspec/**/*.md"] }, // claude code的配置 { code: "claude", value: "claude", desc: "claude code\u7684\u914D\u7F6E\u3002\u7279\u6307\u5728claude code\u751F\u6210\u6216\u4F7F\u7528\u7684\u6587\u4EF6\u3002\u5305\u62EC\u914D\u7F6E\u3001\u63D0\u793A\u8BCD\u3001\u4EE3\u7406\u3001\u8BB0\u5FC6\u6587\u4EF6\u7B49\u3002", glob: ["**/.claude/**", "**/.claude-plugin/**", "**/CLAUDE*.md"] } ]; // src/utils.ts var import_node_path = require("path"); var fs = __toESM(require("fs"), 1); var import_tinyglobby = require("tinyglobby"); var import_js_yaml = require("js-yaml"); var import_lodash = require("lodash"); var import_node_cjs = require("@ruan-cat/utils/node-cjs"); var import_consola = __toESM(require("consola"), 1); var defScopes = [ { name: "root | \u6839\u76EE\u5F55", value: "root" }, { name: "utils | \u5DE5\u5177\u5305", value: "utils" }, { name: "demo | \u6D4B\u8BD5\u9879\u76EE", value: "demo" } ]; function createLabelName(packageJson) { const { name, description } = packageJson; const noneDesc = `\u8BE5\u4F9D\u8D56\u5305\u6CA1\u6709\u63CF\u8FF0\u3002`; const desc = (0, import_lodash.isUndefined)(description) ? noneDesc : description; return `${name ?? "bug\uFF1A\u6781\u7AEF\u60C5\u51B5\uFF0C\u8FD9\u4E2A\u5305\u6CA1\u6709\u914D\u7F6Ename\u540D\u79F0"} >>|>> ${desc}`; } function createPackagescopes(packageJson) { const { name } = packageJson; const names = name == null ? void 0 : name.split("/"); const packageNameWithBusiness = (names == null ? void 0 : names.length) > 1 ? names == null ? void 0 : names[1] : names == null ? void 0 : names[0]; return `${packageNameWithBusiness}`; } function getPackagesNameAndDescription() { if (!(0, import_node_cjs.isMonorepoProject)()) { return defScopes; } const workspaceConfigPath = (0, import_node_path.join)(process.cwd(), "pnpm-workspace.yaml"); const workspaceFile = fs.readFileSync(workspaceConfigPath, "utf8"); const workspaceConfig = (0, import_js_yaml.load)(workspaceFile); const pkgPatterns = workspaceConfig.packages; const filteredPkgPatterns = pkgPatterns.filter((pattern) => { if (pattern.startsWith("!")) return false; if (pattern.trim() === "") return false; return true; }); let pkgPaths = []; filteredPkgPatterns.map((pkgPattern) => { const matchedPath = (0, import_node_cjs.pathChange)((0, import_node_path.join)(process.cwd(), pkgPattern, "package.json")); const matchedPaths = (0, import_tinyglobby.globSync)(matchedPath, { ignore: ["**/node_modules/**"] }); pkgPaths = pkgPaths.concat(...matchedPaths); return matchedPaths; }); const czGitScopesType = pkgPaths.map(function(pkgJsonPath) { if (fs.existsSync(pkgJsonPath)) { if (!pkgJsonPath.endsWith("package.json")) { import_consola.default.warn(`\u8DF3\u8FC7\u975E package.json \u6587\u4EF6: ${pkgJsonPath}`); return null; } try { const fileContent = fs.readFileSync(pkgJsonPath, "utf-8"); const trimmedContent = fileContent.trim(); if (!trimmedContent.startsWith("{")) { import_consola.default.warn(`\u8DF3\u8FC7\u65E0\u6548\u7684 JSON \u6587\u4EF6\uFF08\u5185\u5BB9\u4E0D\u4EE5 { \u5F00\u5934\uFF09: ${pkgJsonPath}`); return null; } const pkgJson = JSON.parse(fileContent); return { // 标签名称 对外展示的标签名称 name: createLabelName(pkgJson), // 取值 value: createPackagescopes(pkgJson) }; } catch (error) { import_consola.default.error(`\u89E3\u6790 package.json \u5931\u8D25: ${pkgJsonPath}`, error); return null; } } import_consola.default.warn(`\u6587\u4EF6\u4E0D\u5B58\u5728: ${pkgJsonPath}`); return null; }).filter((item) => item !== null); return czGitScopesType; } function getDisplayWidth(str) { let width = 0; const chars = Array.from(str); for (const char of chars) { const code = char.codePointAt(0) || 0; if (code >= 127744 && code <= 129535 || // Emoji 主要范围 code >= 9728 && code <= 9983 || // 杂项符号 code >= 9984 && code <= 10175 || // 装饰符号 code >= 65024 && code <= 65039 || // 变体选择器 code >= 126976 && code <= 127023 || // 麻将牌 code >= 127136 && code <= 127231 || // 扑克牌 code >= 127232 && code <= 128591 || // 符号和图形 code >= 128640 && code <= 128767 || // 交通和地图 code >= 129280 && code <= 129535 || // 补充符号和图形 // 中文字符(占 2 宽度) code >= 19968 && code <= 40959 || // CJK 统一汉字 code >= 12288 && code <= 12351 || // CJK 符号和标点 code >= 65280 && code <= 65519) { width += 2; } else { width += 1; } } return width; } function convertCommitTypesToCzGitFormat() { const EMOJI_FIXED_WIDTH = 3; const maxTypeLength = Math.max(...commitTypes.map((commitType) => commitType.type.length)); const maxDescriptionWidth = Math.max(...commitTypes.map((commitType) => getDisplayWidth(commitType.description))); return commitTypes.map((commitType) => { const emojiPart = commitType.emoji + " ".repeat(Math.max(0, EMOJI_FIXED_WIDTH - getDisplayWidth(commitType.emoji))); const typeSpaces = " ".repeat(maxTypeLength - commitType.type.length); const descWidth = getDisplayWidth(commitType.description); const descSpaces = " ".repeat(maxDescriptionWidth - descWidth); const name = commitType.longDescription ? `${emojiPart}${commitType.type}:${typeSpaces} ${commitType.description}${descSpaces} | ${commitType.longDescription}` : `${emojiPart}${commitType.type}:${typeSpaces} ${commitType.description}`; return { value: `${commitType.emoji} ${commitType.type}`, name }; }); } function getTypes() { return commitTypes.map((commitType) => commitType.type); } function getScopes() { return getPackagesNameAndDescription().map( (scope) => ( // 优先从 value 取值,如果 value 不存在,则从 name 取值。 value 才是包名,才是 scope 提交范围。 scope.value ?? scope.name ) ); } // src/get-default-scope.ts var import_node_path2 = require("path"); var fs2 = __toESM(require("fs"), 1); var import_tinyglobby2 = require("tinyglobby"); var import_minimatch = require("minimatch"); var import_js_yaml2 = require("js-yaml"); var import_node_cjs2 = require("@ruan-cat/utils/node-cjs"); var import_node_child_process = require("child_process"); var import_consola2 = __toESM(require("consola"), 1); function parseGitStatusOutput(gitStatusOutput) { return gitStatusOutput.split("\n").filter((line) => line.length > 0).filter((line) => { const indexStatus = line[0]; return indexStatus !== " " && indexStatus !== "?"; }).map((line) => { let filePath = line.substring(2).trim(); return filePath; }).filter((filePath) => filePath.length > 0); } function getPackagePathToScopeMapping() { const mapping = /* @__PURE__ */ new Map(); if (!(0, import_node_cjs2.isMonorepoProject)()) { return mapping; } const workspaceConfigPath = (0, import_node_path2.join)(process.cwd(), "pnpm-workspace.yaml"); const workspaceFile = fs2.readFileSync(workspaceConfigPath, "utf8"); const workspaceConfig = (0, import_js_yaml2.load)(workspaceFile); const pkgPatterns = workspaceConfig.packages; const filteredPkgPatterns = pkgPatterns.filter((pattern) => { if (pattern.startsWith("!")) return false; if (pattern.trim() === "") return false; return true; }); filteredPkgPatterns.forEach((pkgPattern) => { const globPattern = `${pkgPattern}/package.json`; const matchedPaths = (0, import_tinyglobby2.globSync)(globPattern, { cwd: process.cwd(), ignore: ["**/node_modules/**"] }); matchedPaths.forEach((relativePkgPath) => { const fullPkgJsonPath = (0, import_node_path2.join)(process.cwd(), relativePkgPath); if (fs2.existsSync(fullPkgJsonPath)) { if (!relativePkgPath.endsWith("package.json")) { import_consola2.default.warn(`\u8DF3\u8FC7\u975E package.json \u6587\u4EF6: ${relativePkgPath}`); return; } try { const fileContent = fs2.readFileSync(fullPkgJsonPath, "utf-8"); const trimmedContent = fileContent.trim(); if (!trimmedContent.startsWith("{")) { import_consola2.default.warn(`\u8DF3\u8FC7\u65E0\u6548\u7684 JSON \u6587\u4EF6\uFF08\u5185\u5BB9\u4E0D\u4EE5 { \u5F00\u5934\uFF09: ${relativePkgPath}`); return; } const pkgJson = JSON.parse(fileContent); const scope = createPackagescopes(pkgJson); const packageRelativePath = relativePkgPath.replace(/[/\\]package\.json$/, "").replace(/\\/g, "/"); mapping.set(packageRelativePath, scope); } catch (error) { import_consola2.default.error(`\u89E3\u6790 package.json \u5931\u8D25: ${relativePkgPath}`, error); } } }); }); return mapping; } function getDefaultScope() { try { const pathToScopeMapping = getPackagePathToScopeMapping(); const gitStatusOutput = (0, import_node_child_process.execSync)("git status --porcelain || true").toString(); if (!gitStatusOutput) { import_consola2.default.info("\u6CA1\u6709\u68C0\u6D4B\u5230\u6587\u4EF6\u4FEE\u6539"); return void 0; } const modifiedFiles = parseGitStatusOutput(gitStatusOutput); (0, import_node_cjs2.printList)({ title: (files) => `\u8F93\u51FA ${files.length} \u4E2A\u6682\u5B58\u533A\u6587\u4EF6\u8DEF\u5F84:`, stringList: modifiedFiles }); const affectedScopes = /* @__PURE__ */ new Set(); modifiedFiles.forEach((filePath) => { let matchedScope = void 0; let maxMatchLength = 0; for (const [packagePath, scope] of pathToScopeMapping.entries()) { if (packagePath === "") { continue; } const normalizedPackagePath = packagePath.replace(/\\/g, "/"); const normalizedFilePath2 = filePath.replace(/\\/g, "/"); if (normalizedFilePath2.startsWith(normalizedPackagePath + "/") || normalizedFilePath2 === normalizedPackagePath) { if (packagePath.length > maxMatchLength) { maxMatchLength = packagePath.length; matchedScope = scope; } } } if (matchedScope !== void 0) { affectedScopes.add(matchedScope); } const normalizedFilePath = filePath.replace(/\\/g, "/"); commonScopes.forEach((scopeItem) => { if (scopeItem.glob && scopeItem.glob.length > 0) { scopeItem.glob.forEach((globPattern) => { if ((0, import_minimatch.minimatch)(normalizedFilePath, globPattern)) { affectedScopes.add(scopeItem.value); } }); } }); }); const scopesArray = Array.from(affectedScopes); if (scopesArray.length === 0) { import_consola2.default.info("\u672C\u6B21\u4FEE\u6539\u6CA1\u6709\u5F71\u54CD\u4EFB\u4F55\u5305\u8303\u56F4"); return void 0; } else if (scopesArray.length === 1) { return scopesArray[0]; } else { (0, import_node_cjs2.printList)({ title: "\u5F71\u54CD\u7684\u5305\u8303\u56F4:", stringList: scopesArray }); return scopesArray; } } catch (error) { import_consola2.default.error("\u83B7\u53D6\u9ED8\u8BA4\u8303\u56F4\u65F6\u51FA\u9519:", error); return void 0; } } // src/config.ts var config = { /** * @see https://blog.csdn.net/gitblog_00135/article/details/150699293 * @see https://commitlint.js.org/#/reference-rules */ rules: { // 提交类型做报错 "type-enum": [2, "always", getTypes()], // 提交范围做警告 "scope-enum": [1, "always", getScopes()] }, prompt: { alias: { fd: "docs: fix typos" }, messages: { type: "\u9009\u62E9\u4F60\u8981\u63D0\u4EA4\u7684\u7C7B\u578B :", scope: "\u9009\u62E9\u4E00\u4E2A\u63D0\u4EA4\u8303\u56F4\uFF08\u53EF\u9009\uFF09:", customScope: "\u8BF7\u8F93\u5165\u81EA\u5B9A\u4E49\u7684\u63D0\u4EA4\u8303\u56F4 :", subject: "\u586B\u5199\u7B80\u77ED\u7CBE\u70BC\u7684\u53D8\u66F4\u63CF\u8FF0 :\n", body: '\u586B\u5199\u66F4\u52A0\u8BE6\u7EC6\u7684\u53D8\u66F4\u63CF\u8FF0\uFF08\u53EF\u9009\uFF09\u3002\u4F7F\u7528 "|" \u6362\u884C :\n', breaking: '\u5217\u4E3E\u975E\u517C\u5BB9\u6027\u91CD\u5927\u7684\u53D8\u66F4\uFF08\u53EF\u9009\uFF09\u3002\u4F7F\u7528 "|" \u6362\u884C :\n', footerPrefixesSelect: "\u9009\u62E9\u5173\u8054issue\u524D\u7F00\uFF08\u53EF\u9009\uFF09:", customFooterPrefix: "\u8F93\u5165\u81EA\u5B9A\u4E49issue\u524D\u7F00 :", footer: "\u5217\u4E3E\u5173\u8054issue (\u53EF\u9009) \u4F8B\u5982: #31, #I3244 :\n", confirmCommit: "\u662F\u5426\u63D0\u4EA4\u6216\u4FEE\u6539commit ?" }, /** * 基于monorepo内项目,决定提交范围域 * * 该配置可以用 getUserConfig 函数设置 */ // scopes, // https://cz-git.qbb.sh/zh/recipes/#多选模式 enableMultipleScopes: true, scopeEnumSeparator: ",", allowCustomScopes: true, allowEmptyScopes: true, customScopesAlign: "bottom", customScopesAlias: "custom", emptyScopesAlias: "empty", types: convertCommitTypesToCzGitFormat(), useEmoji: true, emojiAlign: "center", useAI: false, aiNumber: 1, themeColorCode: "", upperCaseSubject: false, /** 允许使用破坏性变更的标记 */ markBreakingChangeMode: true, allowBreakingChanges: ["feat", "fix"], breaklineNumber: 100, breaklineChar: "|", skipQuestions: [], issuePrefixes: [ // 如果使用 gitee 作为开发管理 { value: "link", name: "link: \u94FE\u63A5 ISSUES \u8FDB\u884C\u4E2D" }, { value: "closed", name: "closed: \u6807\u8BB0 ISSUES \u5DF2\u5B8C\u6210" } ], customIssuePrefixAlign: "top", emptyIssuePrefixAlias: "skip", customIssuePrefixAlias: "custom", allowCustomIssuePrefix: true, allowEmptyIssuePrefix: true, confirmColorize: true, scopeOverrides: void 0, defaultBody: "", defaultIssues: "", defaultScope: getDefaultScope() || "", defaultSubject: "" } }; // src/changelogen-use-types.ts var import_node_cjs3 = require("@ruan-cat/utils/node-cjs"); var changelogogenUseTypes = Object.fromEntries( commitTypes.map((commitType) => { const { type, description, emoji, semver } = commitType; return [type, { title: `${emoji} ${description}`, semver }]; }).filter( ([type]) => (0, import_node_cjs3.isConditionsSome)([ () => type === "feat", () => type === "fix", () => type === "refactor", () => type === "build", () => type === "config" ]) ) ); // src/index.ts var import_consola3 = require("consola"); var import_lodash2 = require("lodash"); var import_node_cjs4 = require("@ruan-cat/utils/node-cjs"); function isScopesTypeItem(item) { return (0, import_node_cjs4.isConditionsEvery)([ // () => !(0, import_lodash2.isNil)(item), () => (0, import_lodash2.isPlainObject)(item), () => Object.hasOwn(item, "name") ]); } function isScopesItemWithDesc(item) { return (0, import_node_cjs4.isConditionsEvery)([ () => !(0, import_lodash2.isNil)(item), () => (0, import_lodash2.isPlainObject)(item), () => Object.hasOwn(item, "code"), () => Object.hasOwn(item, "value"), () => Object.hasOwn(item, "desc") ]); } function ScopesItemWithDesc_To_ScopesTypeItem(item) { return { name: `${item.code} | ${item.desc}`, value: item.value }; } function getInitScopes() { let scopes = defScopes; scopes = getPackagesNameAndDescription(); return scopes; } function setScopesInUserConfig(params) { const { scopes, userConfig } = params; userConfig.prompt.scopes = scopes; } function getUserConfig(params = {}) { const { userScopes = defScopes, config: config2 = { isPrintScopes: true } } = params; const item = userScopes == null ? void 0 : userScopes[0]; let userScopesInScopesTypeItem = []; if (!(0, import_lodash2.isNil)(item)) { if (isScopesTypeItem(item)) { userScopesInScopesTypeItem = userScopes; } else if (isScopesItemWithDesc(item)) { userScopesInScopesTypeItem = userScopes.map(ScopesItemWithDesc_To_ScopesTypeItem); } else { throw new Error("userScopes \u7684\u7C7B\u578B\u4E0D\u6B63\u786E\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u3002"); } } const commonScopesInScopesTypeItem = commonScopes.map(ScopesItemWithDesc_To_ScopesTypeItem); const initScopes = getInitScopes(); const scopes = (0, import_lodash2.uniqWith)( // 去重 (0, import_lodash2.concat)( // 合并 [], initScopes, commonScopesInScopesTypeItem, userScopesInScopesTypeItem ), // 用对象判断的方式 判断去重 import_lodash2.isEqual ); if ((config2 == null ? void 0 : config2.isPrintScopes) === true) { import_consola3.consola.box(scopes); import_consola3.consola.success(` \u53EF\u7528\u7684\u63D0\u4EA4\u8303\u56F4\u5982\u4E0B\uFF1A `); } const userConfig = defExportCommitlintConfig; setScopesInUserConfig({ scopes, userConfig }); return userConfig; } var defExportCommitlintConfig = (0, import_lodash2.cloneDeep)(config); setScopesInUserConfig({ scopes: defScopes, userConfig: defExportCommitlintConfig }); var index_default = defExportCommitlintConfig; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { changelogogenUseTypes, commitTypes, commonScopes, config, convertCommitTypesToCzGitFormat, createPackagescopes, defScopes, getDefaultScope, getPackagesNameAndDescription, getScopes, getTypes, getUserConfig, parseGitStatusOutput });