create-golden 1.4.3 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +16 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -141,7 +141,7 @@ function saveToken(token) {
|
|
|
141
141
|
|
|
142
142
|
function updateGitignore(projectRoot) {
|
|
143
143
|
const gitignorePath = path.join(projectRoot, '.gitignore');
|
|
144
|
-
const
|
|
144
|
+
const ignoreRules = ['.cursorrules', '代码规范.md', 'AGENTS.md'];
|
|
145
145
|
|
|
146
146
|
try {
|
|
147
147
|
let gitignoreContent = '';
|
|
@@ -149,16 +149,24 @@ function updateGitignore(projectRoot) {
|
|
|
149
149
|
gitignoreContent = fs.readFileSync(gitignorePath, 'utf8');
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
// 检查是否已经包含 .cursorrules
|
|
153
152
|
const lines = gitignoreContent.split('\n');
|
|
154
|
-
|
|
153
|
+
let hasChanges = false;
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
// 检查并添加每个忽略规则
|
|
156
|
+
for (const ignoreRule of ignoreRules) {
|
|
157
|
+
const hasRule = lines.some(line => line.trim() === ignoreRule);
|
|
158
|
+
|
|
159
|
+
if (!hasRule) {
|
|
160
|
+
// 如果文件不为空且最后一行不是空行,添加换行
|
|
161
|
+
if (gitignoreContent && !gitignoreContent.endsWith('\n')) {
|
|
162
|
+
gitignoreContent += '\n';
|
|
163
|
+
}
|
|
164
|
+
gitignoreContent += ignoreRule + '\n';
|
|
165
|
+
hasChanges = true;
|
|
160
166
|
}
|
|
161
|
-
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (hasChanges) {
|
|
162
170
|
fs.writeFileSync(gitignorePath, gitignoreContent, 'utf8');
|
|
163
171
|
}
|
|
164
172
|
} catch (err) {
|