ai-unit-test-generator 2.0.6 β†’ 2.0.7

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/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.7] - 2025-01-11
9
+
10
+ ### πŸ› Hotfix
11
+ - **Fixed**: `ai-test generate` workflow - `batch.mjs` now properly captures `prompt-builder.mjs` stdout and writes to `prompt.txt`
12
+ - Modified `sh()` helper to support stdout capture with `captureStdout` option
13
+ - Resolves missing `prompt.txt` file issue in generation workflow
14
+
15
+ ---
16
+
8
17
  ## [2.0.6] - 2025-01-11
9
18
 
10
19
  ### πŸ› Hotfix
@@ -12,10 +12,24 @@ const __filename = fileURLToPath(import.meta.url)
12
12
  const __dirname = dirname(__filename)
13
13
  const pkgRoot = join(__dirname, '../..')
14
14
 
15
- function sh(cmd, args = []) {
15
+ function sh(cmd, args = [], options = {}) {
16
16
  return new Promise((resolve, reject) => {
17
- const child = spawn(cmd, args, { stdio: 'inherit', cwd: process.cwd() })
18
- child.on('close', code => code === 0 ? resolve(0) : reject(new Error(`${cmd} exited ${code}`)))
17
+ const stdio = options.captureStdout ? ['inherit', 'pipe', 'inherit'] : 'inherit'
18
+ const child = spawn(cmd, args, { stdio, cwd: process.cwd() })
19
+
20
+ const chunks = []
21
+ if (options.captureStdout) {
22
+ child.stdout.on('data', d => chunks.push(Buffer.from(d)))
23
+ }
24
+
25
+ child.on('close', code => {
26
+ if (code === 0) {
27
+ const output = options.captureStdout ? Buffer.concat(chunks).toString('utf8') : null
28
+ resolve(output)
29
+ } else {
30
+ reject(new Error(`${cmd} exited ${code}`))
31
+ }
32
+ })
19
33
  child.on('error', reject)
20
34
  })
21
35
  }
@@ -112,11 +126,16 @@ async function main(argv = process.argv) {
112
126
  '--skip', String(skip),
113
127
  '--only-todo' // ζ–°ε’žοΌšεͺ倄理 TODO ηŠΆζ€
114
128
  ]
129
+
130
+ let promptText
115
131
  try {
116
- await sh('node', [...promptArgs, '--hints-file', 'reports/hints.txt'])
132
+ promptText = await sh('node', [...promptArgs, '--hints-file', 'reports/hints.txt'], { captureStdout: true })
117
133
  } catch {
118
- await sh('node', promptArgs)
134
+ promptText = await sh('node', promptArgs, { captureStdout: true })
119
135
  }
136
+
137
+ // 写ε…₯ prompt.txt
138
+ writeFileSync('prompt.txt', promptText, 'utf-8')
120
139
 
121
140
  // 2) 调用 AI
122
141
  console.log('\nπŸ€– Calling AI...')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-unit-test-generator",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "AI-powered unit test generator with smart priority scoring",
5
5
  "keywords": [
6
6
  "unit-test",