MCPcopy Index your code
hub / github.com/simstudioai/sim / getPreviousIds

Function getPreviousIds

apps/sim/scripts/check-block-registry.ts:96–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94 | { kind: 'ok'; map: IdMap }
95
96function getPreviousIds(): PreviousIdsResult {
97 const registryPath = 'apps/sim/blocks/registry.ts'
98 const blocksDir = 'apps/sim/blocks/blocks'
99
100 let hasChanges = false
101 try {
102 const diff = execSync(
103 `git diff --name-only ${baseRef} HEAD -- ${registryPath} ${blocksDir}`,
104 gitOpts
105 ).trim()
106 hasChanges = diff.length > 0
107 } catch {
108 return { kind: 'skip', reason: 'Could not diff against base ref' }
109 }
110
111 if (!hasChanges) {
112 return { kind: 'noop' }
113 }
114
115 const map: IdMap = {}
116
117 try {
118 const blockFiles = execSync(`git ls-tree -r --name-only ${baseRef} -- ${blocksDir}`, gitOpts)
119 .trim()
120 .split('\n')
121 .filter((f) => f.endsWith('.ts') && !f.endsWith('.test.ts'))
122
123 for (const filePath of blockFiles) {
124 let content: string
125 try {
126 content = execSync(`git show ${baseRef}:${filePath}`, gitOpts)
127 } catch {
128 continue
129 }
130
131 const typeMatch = content.match(/BlockConfig\s*=\s*\{[\s\S]*?type:\s*['"]([^'"]+)['"]/)
132 if (!typeMatch) continue
133 const blockType = typeMatch[1]
134
135 const ids = extractSubBlockIds(content)
136 if (ids.length === 0) continue
137
138 map[blockType] = new Set(ids)
139 }
140 } catch (err) {
141 return { kind: 'skip', reason: `Could not read previous block files from ${baseRef}: ${err}` }
142 }
143
144 return { kind: 'ok', map }
145}
146
147type CheckResult =
148 | { kind: 'pass'; message: string }

Callers 1

checkSubblockIdStabilityFunction · 0.85

Calls 1

extractSubBlockIdsFunction · 0.85

Tested by

no test coverage detected