spec-first-copilot 0.5.0-beta.10 → 0.5.0-beta.12
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/lib/update.js +37 -0
- package/package.json +1 -1
package/lib/update.js
CHANGED
|
@@ -37,6 +37,9 @@ function update({ templatesDir, targetDir, force }) {
|
|
|
37
37
|
const stats = { added: [], updated: [], skipped: 0 };
|
|
38
38
|
syncDir(templatesDir, dest, force, stats, dest);
|
|
39
39
|
|
|
40
|
+
// Auto-configure .gitignore based on sfw.config.yml (before printing results)
|
|
41
|
+
adjustGitignore(dest, stats);
|
|
42
|
+
|
|
40
43
|
console.log('');
|
|
41
44
|
if (stats.added.length > 0) {
|
|
42
45
|
console.log(`Added (${stats.added.length}):`);
|
|
@@ -51,6 +54,7 @@ function update({ templatesDir, targetDir, force }) {
|
|
|
51
54
|
} else {
|
|
52
55
|
console.log(`\n${stats.added.length} added, ${stats.updated.length} updated, ${stats.skipped} unchanged`);
|
|
53
56
|
}
|
|
57
|
+
|
|
54
58
|
console.log('');
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -127,4 +131,37 @@ function isFrameworkPath(rel) {
|
|
|
127
131
|
return false;
|
|
128
132
|
}
|
|
129
133
|
|
|
134
|
+
const WORKSPACE_IGNORE_MARKER = '# SFW: workspace ignored (external backend detected)';
|
|
135
|
+
const WORKSPACE_IGNORE_BLOCK = `
|
|
136
|
+
${WORKSPACE_IGNORE_MARKER}
|
|
137
|
+
# Content lives in the external backend (Confluence, etc.) — local is just cache
|
|
138
|
+
workspace/Output/**
|
|
139
|
+
!workspace/Output/.gitkeep
|
|
140
|
+
`;
|
|
141
|
+
|
|
142
|
+
function adjustGitignore(dest, stats) {
|
|
143
|
+
const configPath = path.join(dest, 'sfw.config.yml');
|
|
144
|
+
const gitignorePath = path.join(dest, '.gitignore');
|
|
145
|
+
|
|
146
|
+
if (!fs.existsSync(configPath) || !fs.existsSync(gitignorePath)) return;
|
|
147
|
+
|
|
148
|
+
const config = fs.readFileSync(configPath, 'utf-8');
|
|
149
|
+
const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
|
|
150
|
+
|
|
151
|
+
const inputMatch = config.match(/^\s*adapter:\s*(\S+)/m);
|
|
152
|
+
const inputAdapter = inputMatch ? inputMatch[1] : 'filesystem';
|
|
153
|
+
const isExternal = inputAdapter !== 'filesystem';
|
|
154
|
+
|
|
155
|
+
const alreadyHasBlock = gitignore.includes(WORKSPACE_IGNORE_MARKER);
|
|
156
|
+
|
|
157
|
+
if (isExternal && !alreadyHasBlock) {
|
|
158
|
+
fs.appendFileSync(gitignorePath, WORKSPACE_IGNORE_BLOCK);
|
|
159
|
+
stats.updated.push('.gitignore (workspace ignored — external backend)');
|
|
160
|
+
} else if (!isExternal && alreadyHasBlock) {
|
|
161
|
+
const cleaned = gitignore.split(WORKSPACE_IGNORE_MARKER)[0].trimEnd() + '\n';
|
|
162
|
+
fs.writeFileSync(gitignorePath, cleaned, 'utf-8');
|
|
163
|
+
stats.updated.push('.gitignore (workspace restored — local mode)');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
130
167
|
module.exports = { update };
|
package/package.json
CHANGED