Skip to content

Commit dc926cc

Browse files
autofix-ci[bot]samwillis
authored andcommitted
ci: apply automated fixes
1 parent 4020dbc commit dc926cc

10 files changed

Lines changed: 149 additions & 99 deletions

packages/db-capacitor-sqlite-persisted-collection/e2e/app/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ async function run(): Promise<void> {
102102
},
103103
})
104104

105-
const failedResults = result.results.filter((entry) => entry.status === `failed`)
105+
const failedResults = result.results.filter(
106+
(entry) => entry.status === `failed`,
107+
)
106108
const summary = {
107109
passed: result.passed,
108110
failed: result.failed,

packages/db-capacitor-sqlite-persisted-collection/e2e/app/src/native-capacitor-sqlite-test-db.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ function createDatabaseName(runId: string, filename: string): string {
2424
export function createNativeCapacitorSQLiteTestDatabaseFactory(options: {
2525
sqlite?: SQLiteConnection
2626
runId: string
27-
}): (databaseOptions: { filename: string }) => NativeCapacitorSQLiteTestDatabase {
27+
}): (databaseOptions: {
28+
filename: string
29+
}) => NativeCapacitorSQLiteTestDatabase {
2830
const sqlite = options.sqlite ?? new SQLiteConnection(CapacitorSQLite)
2931

3032
return ({ filename }) => {
@@ -65,13 +67,7 @@ export function createNativeCapacitorSQLiteTestDatabaseFactory(options: {
6567
},
6668
run: async (statement, values, transaction, returnMode, isSQL92) => {
6769
const database = await connectionPromise
68-
return database.run(
69-
statement,
70-
values,
71-
transaction,
72-
returnMode,
73-
isSQL92,
74-
)
70+
return database.run(statement, values, transaction, returnMode, isSQL92)
7571
},
7672
getDatabaseName: () => databaseName,
7773
}

packages/db-capacitor-sqlite-persisted-collection/e2e/app/src/register-capacitor-e2e-suite.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import type { NativeCapacitorSQLiteTestDatabase } from './native-capacitor-sqlit
55

66
export function registerCapacitorNativeE2ESuite(options: {
77
suiteName: string
8-
createDatabase: (databaseOptions: { filename: string }) => NativeCapacitorSQLiteTestDatabase
8+
createDatabase: (databaseOptions: {
9+
filename: string
10+
}) => NativeCapacitorSQLiteTestDatabase
911
}): void {
1012
const { suiteName, createDatabase } = options
1113
registerPersistedCollectionConformanceSuite({

packages/db-capacitor-sqlite-persisted-collection/e2e/app/src/runtime-vitest.ts

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ function createSuite(name: string, skipped = false): SuiteNode {
4545
}
4646

4747
const rootSuite = createSuite(``)
48-
function formatSuitePath(suites: ReadonlyArray<SuiteNode>, leafName?: string): string {
49-
const segments = suites.map((suite) => suite.name).filter((name) => name.length > 0)
48+
function formatSuitePath(
49+
suites: ReadonlyArray<SuiteNode>,
50+
leafName?: string,
51+
): string {
52+
const segments = suites
53+
.map((suite) => suite.name)
54+
.filter((name) => name.length > 0)
5055
if (leafName && leafName.length > 0) {
5156
segments.push(leafName)
5257
}
@@ -60,7 +65,11 @@ function currentSuite(): SuiteNode {
6065
return suiteStack[suiteStack.length - 1] ?? rootSuite
6166
}
6267

63-
function pushSuite(name: string, skipped: boolean, callback: AsyncCallback): void {
68+
function pushSuite(
69+
name: string,
70+
skipped: boolean,
71+
callback: AsyncCallback,
72+
): void {
6473
const suite = createSuite(name, skipped)
6574
currentSuite().suites.push(suite)
6675

@@ -102,7 +111,11 @@ function resolveTestCallback(
102111
throw new Error(`Test callback must be a function`)
103112
}
104113

105-
function registerTest(name: string, callback: AsyncCallback, skipped: boolean): void {
114+
function registerTest(
115+
name: string,
116+
callback: AsyncCallback,
117+
skipped: boolean,
118+
): void {
106119
currentSuite().tests.push({
107120
name,
108121
fn: callback,
@@ -258,7 +271,9 @@ function createMatchers(
258271
},
259272
toHaveLength(expected: number) {
260273
const actualLength =
261-
typeof actual === `string` || Array.isArray(actual) ? actual.length : undefined
274+
typeof actual === `string` || Array.isArray(actual)
275+
? actual.length
276+
: undefined
262277

263278
assert(
264279
actualLength === expected,
@@ -278,7 +293,10 @@ function createMatchers(
278293
})
279294
}
280295

281-
export function expect(actual: unknown, message?: string): Record<string, unknown> {
296+
export function expect(
297+
actual: unknown,
298+
message?: string,
299+
): Record<string, unknown> {
282300
return createMatchers(actual, message)
283301
}
284302

@@ -315,7 +333,11 @@ export const it: It = Object.assign(
315333
callbackOrOptions: AsyncCallback | Record<string, unknown>,
316334
maybeCallback?: AsyncCallback,
317335
) => {
318-
registerTest(name, resolveTestCallback(callbackOrOptions, maybeCallback), false)
336+
registerTest(
337+
name,
338+
resolveTestCallback(callbackOrOptions, maybeCallback),
339+
false,
340+
)
319341
},
320342
{
321343
skip: (
@@ -363,7 +385,10 @@ export function resetRegisteredTests(): void {
363385
function countTests(suite: SuiteNode): number {
364386
return (
365387
suite.tests.length +
366-
suite.suites.reduce((count, childSuite) => count + countTests(childSuite), 0)
388+
suite.suites.reduce(
389+
(count, childSuite) => count + countTests(childSuite),
390+
0,
391+
)
367392
)
368393
}
369394

@@ -402,7 +427,11 @@ async function runSuite(
402427
total: number
403428
},
404429
options: {
405-
onTestStart?: (context: { name: string; index: number; total: number }) => void
430+
onTestStart?: (context: {
431+
name: string
432+
index: number
433+
total: number
434+
}) => void
406435
},
407436
): Promise<void> {
408437
if (suite.skipped) {
@@ -460,7 +489,8 @@ async function runSuite(
460489
try {
461490
await hook()
462491
} catch (error) {
463-
const message = error instanceof Error ? error.message : String(error)
492+
const message =
493+
error instanceof Error ? error.message : String(error)
464494
results.push({
465495
name: `${testName} afterEach`,
466496
status: `failed`,
@@ -484,9 +514,15 @@ async function runSuite(
484514
)
485515
}
486516

487-
export async function runRegisteredTests(options: {
488-
onTestStart?: (context: { name: string; index: number; total: number }) => void
489-
} = {}): Promise<RegisteredTestRunResult> {
517+
export async function runRegisteredTests(
518+
options: {
519+
onTestStart?: (context: {
520+
name: string
521+
index: number
522+
total: number
523+
}) => void
524+
} = {},
525+
): Promise<RegisteredTestRunResult> {
490526
const results: Array<TestResult> = []
491527
const state = {
492528
index: 0,

packages/db-capacitor-sqlite-persisted-collection/e2e/run-android-e2e.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ function runCommand(
4646
...options.env,
4747
},
4848
stdio:
49-
options.stdio === `pipe`
50-
? [`ignore`, `pipe`, `inherit`]
51-
: `inherit`,
49+
options.stdio === `pipe` ? [`ignore`, `pipe`, `inherit`] : `inherit`,
5250
})
5351

5452
if (options.stdio === `pipe`) {
@@ -135,28 +133,30 @@ async function ensureNativeProject(): Promise<void> {
135133
}
136134

137135
async function resolveAndroidDeviceId(adbPath: string): Promise<string> {
138-
const requestedId = process.env.TANSTACK_DB_CAPACITOR_ANDROID_DEVICE_ID?.trim()
136+
const requestedId =
137+
process.env.TANSTACK_DB_CAPACITOR_ANDROID_DEVICE_ID?.trim()
139138
if (requestedId) {
140139
return requestedId
141140
}
142141

143-
const devicesOutput = await runCommand(
144-
adbPath,
145-
[`devices`],
146-
{ stdio: `pipe` },
147-
)
142+
const devicesOutput = await runCommand(adbPath, [`devices`], {
143+
stdio: `pipe`,
144+
})
148145
const connectedDevices = devicesOutput
149146
.split(`\n`)
150147
.map((line) => line.trim())
151-
.filter((line) => line.endsWith(`device`) && !line.startsWith(`List of devices`))
148+
.filter(
149+
(line) => line.endsWith(`device`) && !line.startsWith(`List of devices`),
150+
)
152151
.map((line) => line.split(/\s+/)[0])
153152

154153
if (connectedDevices.length > 0) {
155154
return connectedDevices[0]!
156155
}
157156

158157
const emulatorPath = resolveSdkBinary(`emulator/emulator`)
159-
const requestedAvd = process.env.TANSTACK_DB_CAPACITOR_ANDROID_AVD_NAME?.trim()
158+
const requestedAvd =
159+
process.env.TANSTACK_DB_CAPACITOR_ANDROID_AVD_NAME?.trim()
160160
const avdName =
161161
requestedAvd ||
162162
(await runCommand(emulatorPath, [`-list-avds`], { stdio: `pipe` }))
@@ -168,23 +168,17 @@ async function resolveAndroidDeviceId(adbPath: string): Promise<string> {
168168
throw new Error(`No Android emulator available`)
169169
}
170170

171-
const emulator = spawn(
172-
emulatorPath,
173-
[`-avd`, avdName, `-no-snapshot-save`],
174-
{
175-
detached: true,
176-
stdio: `ignore`,
177-
},
178-
)
171+
const emulator = spawn(emulatorPath, [`-avd`, avdName, `-no-snapshot-save`], {
172+
detached: true,
173+
stdio: `ignore`,
174+
})
179175
emulator.unref()
180176

181177
const deadline = Date.now() + 180_000
182178
while (Date.now() < deadline) {
183-
const updatedDevicesOutput = await runCommand(
184-
adbPath,
185-
[`devices`],
186-
{ stdio: `pipe` },
187-
)
179+
const updatedDevicesOutput = await runCommand(adbPath, [`devices`], {
180+
stdio: `pipe`,
181+
})
188182
const emulatorDevice = updatedDevicesOutput
189183
.split(`\n`)
190184
.map((line) => line.trim())
@@ -200,7 +194,10 @@ async function resolveAndroidDeviceId(adbPath: string): Promise<string> {
200194
throw new Error(`Timed out waiting for Android emulator to appear`)
201195
}
202196

203-
async function waitForAndroidBoot(adbPath: string, deviceId: string): Promise<void> {
197+
async function waitForAndroidBoot(
198+
adbPath: string,
199+
deviceId: string,
200+
): Promise<void> {
204201
await runCommand(adbPath, [`-s`, deviceId, `wait-for-device`])
205202

206203
const deadline = Date.now() + 180_000

packages/db-capacitor-sqlite-persisted-collection/e2e/run-ios-e2e.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ async function resolveSimulatorId(): Promise<string> {
6868

6969
const devices = await new Promise<string>((resolvePromise, rejectPromise) => {
7070
let output = ``
71-
const child = spawn(`xcrun`, [`simctl`, `list`, `devices`, `available`, `-j`], {
72-
cwd: packageDirectory,
73-
stdio: [`ignore`, `pipe`, `inherit`],
74-
})
71+
const child = spawn(
72+
`xcrun`,
73+
[`simctl`, `list`, `devices`, `available`, `-j`],
74+
{
75+
cwd: packageDirectory,
76+
stdio: [`ignore`, `pipe`, `inherit`],
77+
},
78+
)
7579

7680
child.stdout.on(`data`, (chunk) => {
7781
output += String(chunk)
@@ -104,7 +108,9 @@ async function resolveSimulatorId(): Promise<string> {
104108
.flatMap(([, runtimeDevices]) => runtimeDevices)
105109
.filter((device) => device.isAvailable && device.name.includes(`iPhone`))
106110

107-
const bootedDevice = availableIPhones.find((device) => device.state === `Booted`)
111+
const bootedDevice = availableIPhones.find(
112+
(device) => device.state === `Booted`,
113+
)
108114
if (bootedDevice) {
109115
return bootedDevice.udid
110116
}
@@ -122,7 +128,11 @@ async function resolveSimulatorId(): Promise<string> {
122128

123129
async function ensureNativeProject(): Promise<void> {
124130
const iosProjectDirectory = resolve(appDirectory, `ios`)
125-
const iosXcodeProjectPath = resolve(iosProjectDirectory, `App`, `App.xcodeproj`)
131+
const iosXcodeProjectPath = resolve(
132+
iosProjectDirectory,
133+
`App`,
134+
`App.xcodeproj`,
135+
)
126136
const iosPodfilePath = resolve(iosProjectDirectory, `App`, `Podfile`)
127137

128138
if (existsSync(iosXcodeProjectPath) && !existsSync(iosPodfilePath)) {
@@ -217,20 +227,16 @@ async function waitForResult(): Promise<RuntimeResultRow> {
217227
Promise.resolve(),
218228
)
219229
await runCommand(`xcrun`, [`simctl`, `bootstatus`, simulatorId, `-b`])
220-
await runCommand(`xcrun`, [`simctl`, `terminate`, simulatorId, appId]).catch(() =>
221-
Promise.resolve(),
230+
await runCommand(`xcrun`, [`simctl`, `terminate`, simulatorId, appId]).catch(
231+
() => Promise.resolve(),
232+
)
233+
await runCommand(
234+
`pnpm`,
235+
[`exec`, `cap`, `run`, `ios`, `--target`, simulatorId, `--no-sync`],
236+
{
237+
cwd: appDirectory,
238+
},
222239
)
223-
await runCommand(`pnpm`, [
224-
`exec`,
225-
`cap`,
226-
`run`,
227-
`ios`,
228-
`--target`,
229-
simulatorId,
230-
`--no-sync`,
231-
], {
232-
cwd: appDirectory,
233-
})
234240

235241
const appDataContainer = await resolveAppDataContainer()
236242
const databasePath = resolve(

packages/db-capacitor-sqlite-persisted-collection/src/capacitor-sqlite-driver.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ function isCapacitorSQLiteDatabaseLike(
8585
)
8686
}
8787

88-
function extractQueryRows<T>(result: CapacitorSQLiteValues, sql: string): ReadonlyArray<T> {
88+
function extractQueryRows<T>(
89+
result: CapacitorSQLiteValues,
90+
sql: string,
91+
): ReadonlyArray<T> {
8992
if (Array.isArray(result.values)) {
9093
return result.values as ReadonlyArray<T>
9194
}
@@ -165,7 +168,9 @@ export class CapacitorSQLiteDriver implements SQLiteDriver {
165168
return activeTransactionDriver.transaction(fn)
166169
}
167170

168-
return this.transactionWithDriver((transactionDriver) => fn(transactionDriver))
171+
return this.transactionWithDriver((transactionDriver) =>
172+
fn(transactionDriver),
173+
)
169174
}
170175

171176
async transactionWithDriver<T>(
@@ -311,7 +316,10 @@ export class CapacitorSQLiteDriver implements SQLiteDriver {
311316
await this.database.execute(`RELEASE SAVEPOINT ${savepointName}`, false)
312317
return result
313318
} catch (error) {
314-
await this.database.execute(`ROLLBACK TO SAVEPOINT ${savepointName}`, false)
319+
await this.database.execute(
320+
`ROLLBACK TO SAVEPOINT ${savepointName}`,
321+
false,
322+
)
315323
await this.database.execute(`RELEASE SAVEPOINT ${savepointName}`, false)
316324
throw error
317325
}

0 commit comments

Comments
 (0)