Skip to content

Commit bf4c90b

Browse files
fix(scripts): seed Read fixture paths with JSON escaping
Escape --resource-path before substituting it into the fixture JSON and parse the fixture before creating the destination database. Ignore the browser-pasted Read cache fixture in knip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8c711e7 commit bf4c90b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎knip.jsonc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
],
3131
"ignoreDependencies": ["esbuild"],
3232
// The `t3` npm package's files: copied into the package, never imported.
33-
"ignore": ["npm-launcher/**"],
33+
// The Read cache fixture is pasted into a dev browser, never imported.
34+
"ignore": ["npm-launcher/**", "fixtures/read-cache-web-states.js"],
3435
},
3536
"apps/server": {
3637
// Vite+ pack entries and the launcher used by installed background services.

‎scripts/seed-read-image-cache.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ def chunk(tag, data):
3838
assert '.t3/userdata' not in str(a.home.resolve()), 'Use a disposable evidence home'
3939
dest = a.home / 'userdata/statev2.sqlite'
4040
assert not dest.exists(), 'Refusing to replace an existing database'
41+
# Escape the path for its place inside JSON strings; parse before creating dest.
42+
f = json.loads((Path(__file__).parent / 'fixtures/read-image-cache.json').read_text().replace('/tmp/issue-13138-fixture/outside/square.png', json.dumps(a.resource_path)[1:-1]))
4143
dest.parent.mkdir(parents=True, exist_ok=True)
4244
src = sqlite3.connect(f'file:{a.template.resolve()}?mode=ro', uri=True)
4345
db = sqlite3.connect(dest)
4446
for (sql,) in src.execute("SELECT sql FROM sqlite_master WHERE sql IS NOT NULL AND type='table' AND name NOT LIKE 'sqlite_%'"):
4547
db.execute(sql)
4648
for row in src.execute('SELECT * FROM effect_sql_migrations'):
4749
db.execute('INSERT INTO effect_sql_migrations VALUES (' + ','.join('?' for _ in row) + ')', row)
48-
f = json.loads((Path(__file__).parent / 'fixtures/read-image-cache.json').read_text().replace('/tmp/issue-13138-fixture/outside/square.png', a.resource_path))
4950
def put(table, values):
5051
db.execute(f'INSERT INTO {table} (' + ','.join(values) + ') VALUES (' + ','.join('?' for _ in values) + ')', list(values.values()))
5152
put('projection_projects', f['project'])

0 commit comments

Comments
 (0)