czg-cli failed to load global configuration $HOME/.czrc or $HOME/.cz.json #132
-
我注意到在Windows平台上无法成功读取全局配置 通过阅读源码,加载配置的核心代码应该是 但是似乎只有 调试信息截图: 由于对于源码没有过多研究,所以我疑惑的点是: 为什么只有 如果我的疑惑的多余的,那么我认为只需要在顶层的 如果是的话就赋值 请问我有遗漏了什么地方吗?这么做是否可行?如果没问题的话我很乐意 Pull I noticed that the global configuration cannot be successfully read on the Windows platform. By reading the source code, the core functions responsible for loading the configuration seem to be However, it seems that only Screenshot of the debugging information: ... Since I haven't studied the source code in depth, my points of confusion are: Why is If my doubts are unnecessary, then I believe we only need to check If it is, we can assign Am I missing something? Is this approach feasible? If there are no issues, I would be happy to submit a Pull Request |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
packages/@cz-git/plugin-loader/src/index.ts 这是我调整后的代码,改动就一行代码: 我的理解是当 所以加了个条件继续判断 $HOME 目录内是否存在配置文件,如果存在则赋值。 请问是否可行呢? |
Beta Was this translation helpful? Give feedback.
-
感谢你的调试过程,因为我目前没有 Windows 电脑所以没很好的处理这个事情
因为只有他的配置是只存在
这里 czLoader 与 clLoader 都是依靠了
目前来看要启动两次 cosmiconfig 搜索配置。对于这个问题我持开放状态 PR Welcome。你可以多测试一下,目前我手里没有 Windows 的测试资源,不能很好的 DEBUG |
Beta Was this translation helpful? Give feedback.
-
是的, 我在本地调试了 cosmiconfig/cosmiconfig#278 但是目前我还没有深入阅读源码寻找问题所在,初步测试发现应该是因为 MacOS 是统一的目录结构, 有一个统一的主目录(Home Directory)作为用户的个人文件空间,而在 Windows 上却是使用了分区的概念, 属于分层的目录结构, 通过逻辑磁盘(如C、D、E等)来组织文件和目录。每个逻辑磁盘都有自己的根目录。稍微看了一下源码 测试过程: 我在 最后我提交了一个 PR #133 ,最终改动是
|
Beta Was this translation helpful? Give feedback.
-
环境
操作步骤
使用czg命令时仍然无法读取到全局.czrc中的配置,并且尝试了在使用命令的同一个磁盘的根路径下放一份 看到上面提的pr是为了修复windows系统下无法读取全局配置,下载目前最新版的czg好像没有生效 下面贴上我的 {
"path": "cz-git",
"$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/[email protected]/docs/public/schema/cz-git.json",
"rules": {},
"prompt": {
"alias": {
"fd": "docs: fix typos"
},
"messages": {
"type": "Select the type of change that you're committing:",
"scope": "Denote the SCOPE of this change (optional):",
"customScope": "Denote the SCOPE of this change:",
"subject": "Write a SHORT, IMPERATIVE tense description of the change:\n",
"body": "Provide a LONGER description of the change (optional). Use \"|\" to break new line:\n",
"breaking": "List any BREAKING CHANGES (optional). Use \"|\" to break new line:\n",
"footerPrefixesSelect": "Select the ISSUES type of changeList by this change (optional):",
"customFooterPrefix": "Input ISSUES prefix:",
"footer": "List any ISSUES by this change. E.g.: #31, #34:\n",
"generatingByAI": "Generating your AI commit subject...",
"generatedSelectByAI": "Select suitable subject by AI generated:",
"confirmCommit": "Are you sure you want to proceed with the commit above?"
},
"types": [
{
"value": "feat",
"name": "feat: ✨ A new feature",
"emoji": ":sparkles:"
},
{
"value": "fix",
"name": "fix: 🐛 A bug fix",
"emoji": ":bug:"
},
{
"value": "docs",
"name": "docs: 📝 Documentation only changes",
"emoji": ":memo:"
},
{
"value": "style",
"name": "style: 💄 Changes that do not affect the meaning of the code",
"emoji": ":lipstick:"
},
{
"value": "refactor",
"name": "refactor: ♻️ A code change that neither fixes a bug nor adds a feature",
"emoji": ":recycle:"
},
{
"value": "perf",
"name": "perf: ⚡️ A code change that improves performance",
"emoji": ":zap:"
},
{
"value": "test",
"name": "test: ✅ Adding missing tests or correcting existing tests",
"emoji": ":white_check_mark:"
},
{
"value": "build",
"name": "build: 📦️ Changes that affect the build system or external dependencies",
"emoji": ":package:"
},
{
"value": "ci",
"name": "ci: 🎡 Changes to our CI configuration files and scripts",
"emoji": ":ferris_wheel:"
},
{
"value": "chore",
"name": "chore: 🔨 Other changes that don't modify src or test files",
"emoji": ":hammer:"
},
{
"value": "revert",
"name": "revert: ⏪️ Reverts a previous commit",
"emoji": ":rewind:"
}
],
"useEmoji": true,
"emojiAlign": "center",
"useAI": false,
"aiNumber": 1,
"themeColorCode": "",
"scopes": [],
"allowCustomScopes": true,
"allowEmptyScopes": true,
"customScopesAlign": "bottom",
"customScopesAlias": "custom",
"emptyScopesAlias": "empty",
"upperCaseSubject": false,
"markBreakingChangeMode": false,
"allowBreakingChanges": [
"feat",
"fix"
],
"breaklineNumber": 100,
"breaklineChar": "|",
"skipQuestions": [],
"issuePrefixes": [
{
"value": "closed",
"name": "closed: ISSUES has been processed"
}
],
"customIssuePrefixAlign": "top",
"emptyIssuePrefixAlias": "skip",
"customIssuePrefixAlias": "custom",
"allowCustomIssuePrefix": true,
"allowEmptyIssuePrefix": true,
"confirmColorize": true,
"maxHeaderLength": 100,
"maxSubjectLength": 20,
"minSubjectLength": 0,
"defaultBody": "",
"defaultIssues": "",
"defaultScope": "",
"defaultSubject": ""
}
} 请问一下是我的操作步骤有问题嘛 @13OnTheCode |
Beta Was this translation helpful? Give feedback.
是的, 我在本地调试了
cosmiconfig
, 确实是cosmiconfig
的问题:cosmiconfig/cosmiconfig#278
tal-rofe/cz-vinyl#71
但是目前我还没有深入阅读源码寻找问题所在,初步测试发现应该是因为 MacOS 是统一的目录结构, 有一个统一的主目录(Home Directory)作为用户的个人文件空间,而在 Windows 上却是使用了分区的概念, 属于分层的目录结构, 通过逻辑磁盘(如C、D、E等)来组织文件和目录。每个逻辑磁盘都有自己的根目录。稍微看了一下源码
cosmiconfig
似乎没有对 Windows 系统做额外的处理,不清楚是不是开发人员有意为之还是疏忽了。测试过程:
我在
D:\Developer\13OnTheCode\test\index.js
内执行了cosmiconfig(...).search(...)
那么
cosmiconfig
最后递归到的 "主目录" 是 D 盘,而不是 C 盘所以当 .czrc 配置文件创建在 D 盘的根目录下是可以找到的
最后我提交了一个 PR #133 ,最终改动是
const result = await resultFn(searchPath) ?? await cosmiconfigFn.search(os.homedir())
cosmiconfigFn.search(os.homedir())
因为指定了 C 盘主目录路径,所以我认为不会有性能上的问题,在cosmiconfig
修复这个问题之前,我认为这是目前最优解。稍后我会去阅读co…