Skip to content

Commit 02d9025

Browse files
committed
chore: sync fleet-canonical scripts/fix.mts from socket-repo-template@c7eff9e
Refresh of the auto-fix script to the new fleet-canonical form. Functional change vs. prior local copy: extra argv now flows through to `pnpm run lint --fix`, so `pnpm run fix --all`, `pnpm run fix --staged`, and explicit file paths all work uniformly across the fleet. Eliminates the prior split where socket-addon + socket-stuie used an inline `oxfmt --write . && oxlint --fix` form that rejected `--all`. Both adopted scripts/fix.mts in their own commits today; this brings the rest of the fleet to byte-identical with the new canonical version. Synced byte-identical from socket-repo-template via sync-scaffolding.
1 parent 267cd79 commit 02d9025

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

scripts/fix.mts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
* tools (zizmor, agentshield) if available.
44
*
55
* Steps:
6-
* 1. pnpm run lint --fix — oxlint + oxfmt
7-
* 2. zizmor --fix .github/ — GitHub Actions workflow fixes (if .github/ exists)
8-
* 3. agentshield scan --fix — Claude config fixes (if .claude/ exists)
6+
* 1. pnpm run lint --fix — oxlint + oxfmt (forwards extra argv like --all)
7+
* 2. zizmor --fix .github/ — GitHub Actions workflow fixes
8+
* (skipped if .github/ doesn't exist)
9+
* 3. agentshield scan --fix — Claude config fixes
10+
* (skipped if .claude/ or agentshield isn't installed)
11+
*
12+
* Forwards `process.argv.slice(2)` to the lint step, so
13+
* `pnpm run fix --all` runs `pnpm run lint --fix --all` (full-tree
14+
* fix), and `pnpm run fix --staged` does the staged-only flow.
915
*/
1016

1117
import { existsSync } from 'node:fs'
1218
import process from 'node:process'
1319

14-
import { getDefaultLogger } from '@socketsecurity/lib-stable/logger'
15-
import { spawn } from '@socketsecurity/lib-stable/spawn'
20+
import { getDefaultLogger } from '@socketsecurity/lib/logger'
21+
import { spawn } from '@socketsecurity/lib/spawn'
1622

1723
const WIN32 = process.platform === 'win32'
1824
const logger = getDefaultLogger()
@@ -37,16 +43,19 @@ async function run(
3743
}
3844
return 0
3945
} catch (e) {
46+
const msg = e instanceof Error ? e.message : String(e)
4047
if (!required) {
41-
logger.warn(`${label || cmd}: ${e.message} (non-blocking)`)
48+
logger.warn(`${label || cmd}: ${msg} (non-blocking)`)
4249
return 0
4350
}
4451
throw e
4552
}
4653
}
4754

4855
async function main(): Promise<void> {
49-
// Step 1: Lint fix — delegates to per-package lint scripts.
56+
// Step 1: Lint fix — delegates to scripts/lint.mts which runs both
57+
// oxfmt and oxlint. Forward extra argv so `--all` / `--staged` /
58+
// explicit file paths reach the lint runner unchanged.
5059
const lintExit = await run(
5160
'pnpm',
5261
['run', 'lint', '--fix', ...process.argv.slice(2)],
@@ -76,6 +85,7 @@ async function main(): Promise<void> {
7685
}
7786

7887
main().catch((e: unknown) => {
79-
logger.error(e)
88+
const msg = e instanceof Error ? e.message : String(e)
89+
logger.error(msg)
8090
process.exitCode = 1
8191
})

0 commit comments

Comments
 (0)