scaffold-doc-cli 1.0.4 → 1.0.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.
@@ -14,8 +14,14 @@ async function main() {
14
14
  const output = execSync('git diff --name-only HEAD~1 HEAD').toString();
15
15
  changedFiles = output.split('\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
16
16
  } catch (e) {
17
- console.error("Failed to detect changes:", e.message);
18
- return;
17
+ console.warn("Could not compare with HEAD~1 (likely first commit or shallow fetch). Falling back to listing all files.");
18
+ try {
19
+ const output = execSync('git ls-tree -r --name-only HEAD').toString();
20
+ changedFiles = output.split('\n').filter(f => f && !f.startsWith('.docs') && !f.startsWith('.github'));
21
+ } catch (fallbackError) {
22
+ console.error("Failed to list files:", fallbackError.message);
23
+ return;
24
+ }
19
25
  }
20
26
 
21
27
  if (changedFiles.length === 0) {
@@ -36,7 +42,7 @@ async function main() {
36
42
 
37
43
  // 3. Prompt Gemini
38
44
  const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
39
-
45
+
40
46
  const prompt = `
41
47
  You are a technical documentation assistant.
42
48
  Analyze the following code changes and update the documentation in the .docs/ directory.
@@ -55,7 +61,7 @@ async function main() {
55
61
  try {
56
62
  const result = await model.generateContent(prompt);
57
63
  const text = result.response.text();
58
-
64
+
59
65
  // Simple cleanup if model adds code blocks
60
66
  const jsonStr = text.replace(/\`\`\`json/g, '').replace(/\`\`\`/g, '').trim();
61
67
  const updates = JSON.parse(jsonStr);
@@ -64,11 +70,11 @@ async function main() {
64
70
  for (const [relativePath, content] of Object.entries(updates)) {
65
71
  const fullPath = path.join(process.cwd(), '.docs', relativePath);
66
72
  const dir = path.dirname(fullPath);
67
-
73
+
68
74
  if (!fs.existsSync(dir)) {
69
75
  fs.mkdirSync(dir, { recursive: true });
70
76
  }
71
-
77
+
72
78
  fs.writeFileSync(fullPath, content);
73
79
  console.log(`Updated: .docs/${relativePath}`);
74
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scaffold-doc-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "CLI tool to scaffold standardized documentation structure for projects.",
5
5
  "main": "index.js",
6
6
  "type": "module",