Skip to content

Commit 693225f

Browse files
committed
refactor: add TypeScript types to script files (catch blocks + main functions)
1 parent b8c3eb0 commit 693225f

48 files changed

Lines changed: 124 additions & 124 deletions

Some content is hidden

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

scripts/build.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const registryPath = path.join(rootPath, 'registry')
2222
const args = process.argv.slice(2)
2323
const isQuiet = args.includes('--quiet') || args.includes('--silent')
2424

25-
async function main() {
25+
async function main(): Promise<void> {
2626
// Build the @socketsecurity/registry package.
2727
// This is required before running tests that import from it.
2828
// Pass all arguments through to the registry build script.

scripts/check.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
2828
const rootPath = path.resolve(__dirname, '..')
2929
const registryDistPath = path.join(rootPath, 'registry', 'dist', 'index.js')
3030

31-
async function main() {
31+
async function main(): Promise<void> {
3232
try {
3333
const all = process.argv.includes('--all')
3434
const staged = process.argv.includes('--staged')
@@ -148,13 +148,13 @@ async function main() {
148148
logger.success('All checks passed')
149149
printFooter()
150150
}
151-
} catch (error) {
151+
} catch (error: unknown) {
152152
logger.error(`Check failed: ${error.message}`)
153153
process.exitCode = 1
154154
}
155155
}
156156

157-
main().catch(e => {
157+
main().catch((e: unknown) => {
158158
logger.error(e)
159159
process.exitCode = 1
160160
})

scripts/ci/generate-actions-allow-list.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async function getAllYamlFiles(dir) {
6565
/**
6666
* Generate and display GitHub Actions allow list.
6767
*/
68-
async function main() {
68+
async function main(): Promise<void> {
6969
const allDependencies = new Map()
7070

7171
// Process workflow files.
@@ -181,4 +181,4 @@ async function main() {
181181
}
182182
}
183183

184-
main().catch(e => logger.error(e))
184+
main().catch((e: unknown) => logger.error(e))

scripts/ci/inline-action-versions-as-shas.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async function processFile(filePath, token, dryRun) {
9090
try {
9191
const sha = await resolveRefToSha(owner, repo, ref, { token })
9292
depMap.set(`${owner}/${repoPath}@${ref}`, { owner, ref, repoPath, sha })
93-
} catch (e) {
93+
} catch (e: unknown) {
9494
logger.error(
9595
`Failed to resolve ${owner}/${repoPath}@${ref}: ${e.message}`,
9696
)
@@ -168,7 +168,7 @@ async function getAllYamlFiles(dir) {
168168
/**
169169
* Main function to process all workflow and action files.
170170
*/
171-
async function main() {
171+
async function main(): Promise<void> {
172172
const args = process.argv.slice(2)
173173
const dryRun = args.includes('--dry-run')
174174
const token = process.env.GITHUB_TOKEN || ''
@@ -285,4 +285,4 @@ async function main() {
285285
}
286286
}
287287

288-
main().catch(e => logger.error(e))
288+
main().catch((e: unknown) => logger.error(e))

scripts/ci/show-actions-tree.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async function getAllYamlFiles(dir) {
9191
/**
9292
* Generate and display dependency tree for all GitHub Actions.
9393
*/
94-
async function main() {
94+
async function main(): Promise<void> {
9595
const allDependencies = new Set()
9696
// Map of file -> structured dependencies.
9797
const dependencyTree = new Map()
@@ -184,4 +184,4 @@ async function main() {
184184
logger.info(`Total: ${allDependencies.size} unique actions/workflows`)
185185
}
186186

187-
main().catch(e => logger.error(e))
187+
main().catch((e: unknown) => logger.error(e))

scripts/clean.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function cleanDirectories(tasks, options = {}) {
5454
logger.done(`Cleaned ${name} (already clean)`)
5555
}
5656
}
57-
} catch (error) {
57+
} catch (error: unknown) {
5858
if (!quiet) {
5959
logger.error(`Failed to clean ${name}`)
6060
logger.error(error.message)
@@ -66,7 +66,7 @@ async function cleanDirectories(tasks, options = {}) {
6666
return 0
6767
}
6868

69-
async function main() {
69+
async function main(): Promise<void> {
7070
try {
7171
// Parse arguments
7272
const { values } = parseArgs({
@@ -202,10 +202,10 @@ async function main() {
202202
logger.success('Clean completed successfully!')
203203
}
204204
}
205-
} catch (error) {
205+
} catch (error: unknown) {
206206
logger.error(`Clean runner failed: ${error.message}`)
207207
process.exitCode = 1
208208
}
209209
}
210210

211-
main().catch(e => logger.error(e))
211+
main().catch((e: unknown) => logger.error(e))

scripts/cover.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ try {
305305
}
306306

307307
process.exitCode = exitCode
308-
} catch (error) {
308+
} catch (error: unknown) {
309309
logger.error(`Coverage script failed: ${error.message}`)
310310
process.exitCode = 1
311311
}

scripts/fix.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function run(cmd, args, { label, required = true } = {}) {
3232
logger.warn(`${label || cmd}: exited ${result.code} (non-blocking)`)
3333
}
3434
return 0
35-
} catch (e) {
35+
} catch (e: unknown) {
3636
if (!required) {
3737
logger.warn(`${label || cmd}: ${e.message} (non-blocking)`)
3838
return 0
@@ -41,7 +41,7 @@ async function run(cmd, args, { label, required = true } = {}) {
4141
}
4242
}
4343

44-
async function main() {
44+
async function main(): Promise<void> {
4545
// Step 1: Lint fix — delegates to per-package lint scripts.
4646
const lintExit = await run(
4747
'pnpm',
@@ -71,7 +71,7 @@ async function main() {
7171
}
7272
}
7373

74-
main().catch(e => {
74+
main().catch((e: unknown) => {
7575
logger.error(e)
7676
process.exitCode = 1
7777
})

scripts/lint.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async function getFilesToLint(options) {
321321
return { files: lintableFiles, reason: undefined, mode }
322322
}
323323

324-
async function main() {
324+
async function main(): Promise<void> {
325325
try {
326326
// Parse arguments
327327
const { positionals, values } = parseArgs({
@@ -441,10 +441,10 @@ async function main() {
441441
logger.success('All lint checks passed!')
442442
}
443443
}
444-
} catch (error) {
444+
} catch (error: unknown) {
445445
logger.error(`Lint runner failed: ${error.message}`)
446446
process.exitCode = 1
447447
}
448448
}
449449

450-
main().catch(e => logger.error(e))
450+
main().catch((e: unknown) => logger.error(e))

scripts/maintenance/taze.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function includesProvenanceDowngradeWarning(output) {
1515
)
1616
}
1717

18-
async function main() {
18+
async function main(): Promise<void> {
1919
// Run with command line arguments.
2020
const args = process.argv.slice(2)
2121

@@ -62,4 +62,4 @@ async function main() {
6262
await tazePromise
6363
}
6464

65-
main().catch(e => logger.error(e))
65+
main().catch((e: unknown) => logger.error(e))

0 commit comments

Comments
 (0)