Skip to content

Commit da3be8a

Browse files
committed
style: apply biome 2.x safe autofixes across the repo
Now that biome.json parses under biome 2.x (#517), run `biome check --write` to clear the backlog of auto-fixable findings that were invisible while the config was unparseable. Safe fixes only — formatting reflow plus safe lint fixes (import sorting, etc.). The 351 unsafe fixes and the remaining non-autofixable lint findings are intentionally left for manual follow-up. Mechanical change; no behavior change. Verified: CLI suite (312 tests) and script self-tests (20) pass; reformatted packages with credential-free unit tests pass; the remaining monorepo test failures are pre-existing DB-integration tests (Missing DATABASE_URL) that fail identically on the base branch.
1 parent f146e6e commit da3be8a

296 files changed

Lines changed: 8123 additions & 6501 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

e2e/tests/package-managers.e2e.test.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ const BIN = {
2626
cli: resolve(REPO_ROOT, 'packages/cli/dist/bin/stash.js'),
2727
wizard: resolve(REPO_ROOT, 'packages/wizard/dist/bin/wizard.js'),
2828
protect: resolve(REPO_ROOT, 'packages/protect/dist/bin/stash.js'),
29-
drizzleGen: resolve(REPO_ROOT, 'packages/drizzle/dist/bin/generate-eql-migration.js'),
29+
drizzleGen: resolve(
30+
REPO_ROOT,
31+
'packages/drizzle/dist/bin/generate-eql-migration.js',
32+
),
3033
} as const
3134

3235
const UA: Record<PackageManager, string> = {
@@ -48,14 +51,12 @@ describe('CLI init providers — package-manager-aware Next Steps', () => {
4851
{
4952
label: 'base',
5053
create: createBaseProvider,
51-
firstStep: (r) =>
52-
`Set up your database: ${r} stash db install`,
54+
firstStep: (r) => `Set up your database: ${r} stash db install`,
5355
},
5456
{
5557
label: 'drizzle',
5658
create: createDrizzleProvider,
57-
firstStep: (r) =>
58-
`Set up your database: ${r} stash db install --drizzle`,
59+
firstStep: (r) => `Set up your database: ${r} stash db install --drizzle`,
5960
},
6061
{
6162
label: 'supabase',
@@ -201,13 +202,18 @@ describe.skipIf(!authConfigured)(
201202
// in their --help output when executed under different package manager environments.
202203
describe('binaries — help text uses detected runner', () => {
203204
for (const pm of PMS) {
204-
for (const [name, bin] of Object.entries(BIN) as Array<[keyof typeof BIN, string]>) {
205+
for (const [name, bin] of Object.entries(BIN) as Array<
206+
[keyof typeof BIN, string]
207+
>) {
205208
it(`${name} --help renders ${RUNNER[pm]} for pm=${pm}`, () => {
206209
const result = spawnSync('node', [bin, '--help'], {
207210
env: { ...process.env, npm_config_user_agent: UA[pm] },
208211
encoding: 'utf8',
209212
})
210-
expect(result.status, `${name} --help (pm=${pm}) stderr: ${result.stderr}`).toBe(0)
213+
expect(
214+
result.status,
215+
`${name} --help (pm=${pm}) stderr: ${result.stderr}`,
216+
).toBe(0)
211217
expect(result.stdout).toContain(RUNNER[pm])
212218
if (RUNNER[pm] !== 'npx') {
213219
expect(result.stdout).not.toMatch(/\bnpx\b/)

e2e/tests/prisma-example-readme.e2e.test.ts

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { spawnSync } from 'node:child_process'
2-
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
2+
import {
3+
cpSync,
4+
existsSync,
5+
mkdirSync,
6+
mkdtempSync,
7+
readFileSync,
8+
rmSync,
9+
} from 'node:fs'
310
import { tmpdir } from 'node:os'
411
import { dirname, join, resolve } from 'node:path'
512
import { fileURLToPath } from 'node:url'
@@ -29,9 +36,12 @@ function describeSpawnFailure(result: StepResult): string {
2936
const lines = [`step \`${result.label}\` failed.`]
3037
if (result.error) lines.push(` spawn error: ${result.error.message}`)
3138
if (result.signal) lines.push(` killed by signal: ${result.signal}`)
32-
if (typeof result.status === 'number') lines.push(` exit status: ${result.status}`)
33-
if (result.stderr.trim()) lines.push(`--- stderr ---\n${result.stderr.trim()}`)
34-
if (result.stdout.trim()) lines.push(`--- stdout ---\n${result.stdout.trim()}`)
39+
if (typeof result.status === 'number')
40+
lines.push(` exit status: ${result.status}`)
41+
if (result.stderr.trim())
42+
lines.push(`--- stderr ---\n${result.stderr.trim()}`)
43+
if (result.stdout.trim())
44+
lines.push(`--- stdout ---\n${result.stdout.trim()}`)
3545
return lines.join('\n')
3646
}
3747

@@ -131,41 +141,49 @@ function timeoutFor(line: string): number {
131141
const README_COMMANDS = parseRunItCommands(
132142
readFileSync(resolve(EXAMPLE_DIR, 'README.md'), 'utf8'),
133143
)
134-
const EXECUTED_COMMANDS = README_COMMANDS.filter((line) => !SKIP_COMMANDS.has(line))
144+
const EXECUTED_COMMANDS = README_COMMANDS.filter(
145+
(line) => !SKIP_COMMANDS.has(line),
146+
)
135147

136148
const outcomes = new Map<string, StepResult>()
137149
let snapDir: string
138150

139-
describe.skipIf(!authConfigured)('examples/prisma README "Run it" walkthrough', () => {
140-
beforeAll(async () => {
141-
snapDir = await snapshotTransientOutputs()
142-
await wipeTransientOutputs()
143-
144-
// Drive the walkthrough straight from the parsed README. `bash -c` keeps
145-
// fidelity with what a user actually types — no argv tokenizer needed,
146-
// future README evolutions (operators, quoting) Just Work.
147-
for (const line of README_COMMANDS) {
148-
if (SKIP_COMMANDS.has(line)) {
149-
console.log(`[readme-walkthrough] skip: ${line}`)
150-
continue
151+
describe.skipIf(!authConfigured)(
152+
'examples/prisma README "Run it" walkthrough',
153+
() => {
154+
beforeAll(async () => {
155+
snapDir = await snapshotTransientOutputs()
156+
await wipeTransientOutputs()
157+
158+
// Drive the walkthrough straight from the parsed README. `bash -c` keeps
159+
// fidelity with what a user actually types — no argv tokenizer needed,
160+
// future README evolutions (operators, quoting) Just Work.
161+
for (const line of README_COMMANDS) {
162+
if (SKIP_COMMANDS.has(line)) {
163+
console.log(`[readme-walkthrough] skip: ${line}`)
164+
continue
165+
}
166+
outcomes.set(line, runStep(line, timeoutFor(line)))
151167
}
152-
outcomes.set(line, runStep(line, timeoutFor(line)))
153-
}
154-
}, 600_000) // 10 min total budget for the cold path
155-
156-
afterAll(async () => {
157-
// Teardown the bundled Postgres container regardless of outcome.
158-
runStep('docker compose down -v', 60_000)
159-
// Restore the transient outputs from snapshot so the working tree is clean.
160-
await restoreTransientOutputs(snapDir)
161-
// Remove the .env we copied in the walkthrough (not tracked anyway).
162-
rmSync(join(EXAMPLE_DIR, '.env'), { force: true })
163-
}, 120_000)
164-
165-
// Per-step exit-zero assertion, registered once per non-skipped README line.
166-
it.each(EXECUTED_COMMANDS)('README "Run it" step exited 0: %s', (line) => {
167-
const r = outcomes.get(line)
168-
expect(r, `no outcome recorded for \`${line}\` — beforeAll did not run this step`).toBeDefined()
169-
expect(r!.status, describeSpawnFailure(r!)).toBe(0)
170-
})
171-
})
168+
}, 600_000) // 10 min total budget for the cold path
169+
170+
afterAll(async () => {
171+
// Teardown the bundled Postgres container regardless of outcome.
172+
runStep('docker compose down -v', 60_000)
173+
// Restore the transient outputs from snapshot so the working tree is clean.
174+
await restoreTransientOutputs(snapDir)
175+
// Remove the .env we copied in the walkthrough (not tracked anyway).
176+
rmSync(join(EXAMPLE_DIR, '.env'), { force: true })
177+
}, 120_000)
178+
179+
// Per-step exit-zero assertion, registered once per non-skipped README line.
180+
it.each(EXECUTED_COMMANDS)('README "Run it" step exited 0: %s', (line) => {
181+
const r = outcomes.get(line)
182+
expect(
183+
r,
184+
`no outcome recorded for \`${line}\` — beforeAll did not run this step`,
185+
).toBeDefined()
186+
expect(r!.status, describeSpawnFailure(r!)).toBe(0)
187+
})
188+
},
189+
)

e2e/tests/supply-chain.e2e.test.ts

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ describe('supply chain — pnpm configuration', () => {
3434
})
3535

3636
it('pnpm-workspace.yaml sets blockExoticSubdeps: true', () => {
37-
const ws = readYaml('pnpm-workspace.yaml') as { blockExoticSubdeps?: boolean }
37+
const ws = readYaml('pnpm-workspace.yaml') as {
38+
blockExoticSubdeps?: boolean
39+
}
3840
expect(ws.blockExoticSubdeps).toBe(true)
3941
})
4042

4143
it('onlyBuiltDependencies remains a small explicit allowlist (≤3 entries)', () => {
42-
const allow = (readJson('package.json').pnpm?.onlyBuiltDependencies ?? []) as string[]
44+
const allow = (readJson('package.json').pnpm?.onlyBuiltDependencies ??
45+
[]) as string[]
4346
expect(Array.isArray(allow)).toBe(true)
4447
expect(allow.length).toBeLessThanOrEqual(3)
4548
})
@@ -48,7 +51,9 @@ describe('supply chain — pnpm configuration', () => {
4851
describe('supply chain — registry pinning (.npmrc)', () => {
4952
it('pins @cipherstash scope and default registry to npmjs', () => {
5053
const npmrc = read('.npmrc')
51-
expect(npmrc).toMatch(/^@cipherstash:registry=https:\/\/registry\.npmjs\.org\/$/m)
54+
expect(npmrc).toMatch(
55+
/^@cipherstash:registry=https:\/\/registry\.npmjs\.org\/$/m,
56+
)
5257
expect(npmrc).toMatch(/^registry=https:\/\/registry\.npmjs\.org\/$/m)
5358
})
5459

@@ -62,7 +67,10 @@ describe('supply chain — registry pinning (.npmrc)', () => {
6267
describe('supply chain — pnpm-lock.yaml integrity', () => {
6368
it('every resolved package comes from registry.npmjs.org (no git/tarball deps)', () => {
6469
const lock = readYaml('pnpm-lock.yaml') as {
65-
packages?: Record<string, { resolution?: { tarball?: string; type?: string } }>
70+
packages?: Record<
71+
string,
72+
{ resolution?: { tarball?: string; type?: string } }
73+
>
6674
}
6775
const offenders: string[] = []
6876
for (const [name, entry] of Object.entries(lock.packages ?? {})) {
@@ -90,7 +98,11 @@ describe('supply chain — CI hardening (.github/workflows/tests.yml)', () => {
9098
string,
9199
{
92100
strategy?: { matrix?: Record<string, unknown> }
93-
steps: Array<{ run?: string; uses?: string; with?: Record<string, unknown> }>
101+
steps: Array<{
102+
run?: string
103+
uses?: string
104+
with?: Record<string, unknown>
105+
}>
94106
}
95107
>
96108
}
@@ -105,7 +117,9 @@ describe('supply chain — CI hardening (.github/workflows/tests.yml)', () => {
105117
(s) => typeof s.run === 'string' && PNPM_INSTALL.test(s.run),
106118
)
107119
for (const step of installSteps) {
108-
expect(step.run, `${jobName} step "${step.run}"`).toMatch(/--frozen-lockfile/)
120+
expect(step.run, `${jobName} step "${step.run}"`).toMatch(
121+
/--frozen-lockfile/,
122+
)
109123
}
110124
}
111125
})
@@ -114,29 +128,40 @@ describe('supply chain — CI hardening (.github/workflows/tests.yml)', () => {
114128
for (const [jobName, job] of Object.entries(workflow.jobs)) {
115129
const usesPnpm = job.steps.some(
116130
(s) =>
117-
(typeof s.uses === 'string' && s.uses.startsWith('pnpm/action-setup')) ||
131+
(typeof s.uses === 'string' &&
132+
s.uses.startsWith('pnpm/action-setup')) ||
118133
(typeof s.run === 'string' && /\bpnpm\b/.test(s.run)),
119134
)
120135
if (!usesPnpm) continue
121136
const setup = job.steps.find(
122-
(s) => typeof s.uses === 'string' && s.uses.startsWith('actions/setup-node'),
137+
(s) =>
138+
typeof s.uses === 'string' && s.uses.startsWith('actions/setup-node'),
123139
)
124-
expect(setup, `${jobName} uses pnpm but lacks actions/setup-node`).toBeTruthy()
140+
expect(
141+
setup,
142+
`${jobName} uses pnpm but lacks actions/setup-node`,
143+
).toBeTruthy()
125144
const nv = String(setup?.with?.['node-version'])
126145
if (nv === '22') continue
127146
// Allow `${{ matrix.<key> }}` only when that matrix key resolves to
128147
// an array of versions that includes 22 — so the matrix can broaden
129148
// coverage without ever dropping the Node 22 hardening baseline.
130149
const matrixRef = nv.match(/^\$\{\{\s*matrix\.([\w-]+)\s*\}\}$/)
131-
expect(matrixRef, `${jobName} node version: expected '22' or matrix expression, got '${nv}'`).toBeTruthy()
150+
expect(
151+
matrixRef,
152+
`${jobName} node version: expected '22' or matrix expression, got '${nv}'`,
153+
).toBeTruthy()
132154
const matrixKey = matrixRef![1]
133155
const versions = job.strategy?.matrix?.[matrixKey]
134156
expect(
135157
Array.isArray(versions),
136158
`${jobName} references matrix.${matrixKey} but no such array on strategy.matrix`,
137159
).toBe(true)
138160
const versionStrings = (versions as unknown[]).map((v) => String(v))
139-
expect(versionStrings, `${jobName} matrix.${matrixKey} must include 22`).toContain('22')
161+
expect(
162+
versionStrings,
163+
`${jobName} matrix.${matrixKey} must include 22`,
164+
).toContain('22')
140165
}
141166
})
142167
})
@@ -156,7 +181,9 @@ describe('supply chain — automated dependency updates (Dependabot)', () => {
156181
})
157182

158183
it('github-actions ecosystem is also covered with a ≥ 3 day cooldown', () => {
159-
const gha = db.updates.find((u) => u['package-ecosystem'] === 'github-actions')
184+
const gha = db.updates.find(
185+
(u) => u['package-ecosystem'] === 'github-actions',
186+
)
160187
expect(gha).toBeDefined()
161188
expect(gha?.cooldown?.['default-days']).toBeGreaterThanOrEqual(3)
162189
})
@@ -183,7 +210,9 @@ describe('supply chain — governance (CODEOWNERS)', () => {
183210
const rule = rules.find((l) => l.includes(path))
184211
expect(rule, `no CODEOWNERS rule covers ${path}`).toBeDefined()
185212
const owners = rule!.split(/\s+/).slice(1)
186-
expect(owners, `${path} CODEOWNERS owners`).toContain('@cipherstash/developers')
213+
expect(owners, `${path} CODEOWNERS owners`).toContain(
214+
'@cipherstash/developers',
215+
)
187216
}
188217
})
189218
})

examples/basic/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dotenv/config'
22
import readline from 'node:readline'
33
import { client, users } from './encrypt'
4-
import { getAllContacts, createContact } from './src/queries/contacts'
4+
import { createContact, getAllContacts } from './src/queries/contacts'
55

66
const rl = readline.createInterface({
77
input: process.stdin,
@@ -78,7 +78,7 @@ async function main() {
7878
const newContact = {
7979
name: 'John Doe',
8080
email: 'john@example.com',
81-
role: 'Developer' // This field will be encrypted using CipherStash
81+
role: 'Developer', // This field will be encrypted using CipherStash
8282
}
8383

8484
// Note: This would fail in this basic example since we don't have actual Supabase setup
@@ -89,9 +89,10 @@ async function main() {
8989
console.log('Fetching encrypted contacts...')
9090
// const contacts = await getAllContacts()
9191
// console.log('Decrypted contacts:', contacts.data)
92-
9392
} catch (error) {
94-
console.log('Supabase demo skipped (no actual Supabase connection in this basic example)')
93+
console.log(
94+
'Supabase demo skipped (no actual Supabase connection in this basic example)',
95+
)
9596
}
9697

9798
rl.close()

examples/basic/src/encryption/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { pgTable, integer, timestamp } from 'drizzle-orm/pg-core'
2-
import { encryptedType, extractEncryptionSchema } from '@cipherstash/stack/drizzle'
31
import { Encryption } from '@cipherstash/stack'
2+
import {
3+
encryptedType,
4+
extractEncryptionSchema,
5+
} from '@cipherstash/stack/drizzle'
6+
import { integer, pgTable, timestamp } from 'drizzle-orm/pg-core'
47

58
export const usersTable = pgTable('users', {
69
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { encryptedSupabase } from '@cipherstash/stack/supabase'
2-
import { encryptionClient, contactsTable } from '../../encryption/index'
2+
import { contactsTable, encryptionClient } from '../../encryption/index'
33
import { createServerClient } from './server'
44

55
const supabase = await createServerClient()
66
export const eSupabase = encryptedSupabase({
77
encryptionClient,
88
supabaseClient: supabase,
9-
})
9+
})

examples/basic/src/lib/supabase/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export async function createServerClient() {
55
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
66

77
return createClient(supabaseUrl, supabaseKey)
8-
}
8+
}

0 commit comments

Comments
 (0)