Direct store API traces: comment lines are skipped and each file names a tool once (a real project listed one script five times, mostly doc comments)
This commit is contained in:
parent
5bfbcefffa
commit
ee35b11341
2 changed files with 13 additions and 2 deletions
|
|
@ -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 });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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' })]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue