diff --git a/cli/lib/fastlane-traces.ts b/cli/lib/fastlane-traces.ts index ddc0668..fc847de 100644 --- a/cli/lib/fastlane-traces.ts +++ b/cli/lib/fastlane-traces.ts @@ -72,9 +72,11 @@ export function findFastlaneTraces(root: string): FastlaneTrace[] { lines(f).forEach((l, i) => { const m = CLI_CALL.exec(l); if (m) out.push({ file: rel(f), line: i + 1, text: l.trim().slice(0, 200), store: storeOf(m[1]!) }); - else if (!/package\.json$/.test(f) || /"[^"]*"\s*:\s*"/.test(l)) { + // comment lines name the tools without calling them; one line per file and tool is enough (a real project + // listed the same script five times, mostly from its doc comments) + else if ((!/package\.json$/.test(f) || /"[^"]*"\s*:\s*"/.test(l)) && !/^\s*(\/\/|\/?\*|#|--|REM\b)/i.test(l)) { const d = DIRECT.find(x => x.re.test(l)); - if (d) out.push({ file: rel(f), line: i + 1, text: l.trim().slice(0, 200), store: d.store, via: 'api', fix: d.fix }); + if (d && !out.some(o => o.file === rel(f) && o.fix === d.fix)) out.push({ file: rel(f), line: i + 1, text: l.trim().slice(0, 200), store: d.store, via: 'api', fix: d.fix }); } }); } diff --git a/tests/fastlane-traces.test.ts b/tests/fastlane-traces.test.ts index 5b7a4df..7d03491 100644 --- a/tests/fastlane-traces.test.ts +++ b/tests/fastlane-traces.test.ts @@ -56,3 +56,12 @@ describe('fastlane traces', () => { expect(f?.fix).toContain('storebound import fastlane'); }); }); + +describe('direct store API traces stay short', () => { + test('comment lines are skipped and each file names a tool once', () => { + const dir = mkdtempSync(join(tmpdir(), 'sb-fl2-')); + mkdirSync(join(dir, 'tools')); + writeFileSync(join(dir, 'tools/ship.mjs'), "/**\n * 4. `xcrun altool --upload-package` uploads it\n */\n// altool needs the app id\nconst words = ['xcrun', 'altool', '--upload-package'];\nrun(['xcrun', 'altool', '--validate-app']);\n"); + expect(findFastlaneTraces(dir)).toEqual([expect.objectContaining({ file: 'tools/ship.mjs', line: 5, via: 'api' })]); + }); +});