MCPcopy Create free account
hub / github.com/TanStack/cli / getFileProvenance

Function getFileProvenance

packages/create/src/attribution.ts:41–90  ·  view source on GitHub ↗
(
  filePath: string,
  framework: Framework,
  addOns: Array<AddOn>,
  starter?: Starter,
)

Source from the content-addressed store, hash-verified

39}
40
41async function getFileProvenance(
42 filePath: string,
43 framework: Framework,
44 addOns: Array<AddOn>,
45 starter?: Starter,
46): Promise<FileProvenance | null> {
47 const target = filePath.startsWith('./') ? filePath.slice(2) : filePath
48
49 if (starter) {
50 const files = await starter.getFiles()
51 if (files.some((f: string) => normalizePath(f) === target)) {
52 return {
53 source: 'starter',
54 sourceId: starter.id,
55 sourceName: starter.name,
56 }
57 }
58 }
59
60 // Order add-ons by type then phase (matches writeFiles order), check in reverse
61 const typeOrder = ['add-on', 'example', 'toolchain', 'deployment']
62 const phaseOrder = ['setup', 'add-on', 'example']
63 const ordered = typeOrder.flatMap((type) =>
64 phaseOrder.flatMap((phase) =>
65 addOns.filter((a) => a.phase === phase && a.type === type),
66 ),
67 )
68
69 for (let i = ordered.length - 1; i >= 0; i--) {
70 const files = await ordered[i].getFiles()
71 if (files.some((f: string) => normalizePath(f) === target)) {
72 return {
73 source: 'add-on',
74 sourceId: ordered[i].id,
75 sourceName: ordered[i].name,
76 }
77 }
78 }
79
80 const frameworkFiles = await framework.getFiles()
81 if (frameworkFiles.some((f: string) => normalizePath(f) === target)) {
82 return {
83 source: 'framework',
84 sourceId: framework.id,
85 sourceName: framework.name,
86 }
87 }
88
89 return null
90}
91
92// Build injection patterns from integrations (for source files)
93function integrationInjections(int: IntegrationWithSource): Array<Injection> {

Callers 1

computeAttributionFunction · 0.85

Calls 1

normalizePathFunction · 0.70

Tested by

no test coverage detected