fix(mobile): format emitted RPC foundation artifacts so regeneration cannot leave CI red

`emit` wrote `JSON.stringify(value, null, 2)` while `format:check` runs oxfmt
over the same committed bytes, so the short `scope` array failed the gate.
The generator now formats what it writes; `--check` compares parsed JSON and
is unaffected.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
Jinwoo-H
2026-09-10 14:08:45 -04:00
parent 5131e078ad
commit 1cfd6ab7cb
5 changed files with 18 additions and 12 deletions
+1 -4
View File
@@ -1,9 +1,6 @@
{
"schemaVersion": 2,
"scope": [
"mobile/src",
"mobile/app"
],
"scope": ["mobile/src", "mobile/app"],
"summary": {
"callSites": 431,
"literalMethod": 387,
+1 -1
View File
@@ -78,7 +78,7 @@ calls.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column
const rows = calls.map(
(call) => `${call.file}:${call.line}:${call.column} ${call.kind} ${call.method}`
)
emit('access-inventory', {
await emit('access-inventory', {
schemaVersion: 2,
scope: ['mobile/src', 'mobile/app'],
summary: {
+14 -5
View File
@@ -26,16 +26,25 @@ export async function git(...args: string[]): Promise<string> {
}
return result.stdout.trimEnd()
}
export function emit(name: string, value: unknown): void {
export async function emit(name: string, value: unknown): Promise<void> {
const path = resolve(root, option('output', `mobile/rpc-foundation/${name}.json`))
if (process.argv.includes('--check')) {
if (!isDeepStrictEqual(JSON.parse(readFileSync(path, 'utf8')), value)) {
throw new Error(`Stale artifact: ${path}`)
}
console.log(`${name}: current`)
} else {
mkdirSync(dirname(path), { recursive: true })
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`)
console.log(`${name}: ${path}`)
return
}
mkdirSync(dirname(path), { recursive: true })
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`)
// Committed artifacts are checked by `format:check`; format here so regeneration cannot leave CI red.
const formatted = await runProcess({
program: resolve(root, 'node_modules/.bin/oxfmt'),
args: ['--write', path],
cwd: root
})
if (formatted.code !== 0) {
throw new Error(`oxfmt --write ${path}: ${formatted.stderr}`)
}
console.log(`${name}: ${path}`)
}
+1 -1
View File
@@ -26,7 +26,7 @@ const entries = sources.map((file) => {
rpcCandidates
}
})
emit('native-rpc-inventory', {
await emit('native-rpc-inventory', {
schemaVersion: 1,
scope: ['mobile/packages', 'mobile/plugins'],
extensions: ['swift', 'kt', 'm', 'mm', 'h', 'java'],
+1 -1
View File
@@ -119,7 +119,7 @@ results.push({
for (const result of results) {
assert.equal(result.killed, true, `${result.id}: reference no longer exhibits the known defect`)
}
emit('reference-regressions', {
await emit('reference-regressions', {
revision,
sources,
supportingFunctions: ['rankSuggestions', 'buildGithubPrParams', 'githubPrRepoSlugParam'],