Skip to content

Commit d2cab0c

Browse files
committed
refactor(cli/scripts): colocate 63 unused exports across 22 scripts
These are standalone build/test/setup scripts whose internal helpers were exported for no reason — every helper was only called inside its own file. Touched scripts: - constants/{build,paths,packages,external-tools-platforms}.mts - {build,build-sea,download-assets,esbuild-utils,paths,restore-cache, sync-checksums,test-download-external-tools,test-sea,test-wrapper, validate-bundle,validate-tests,wasm}.mts - sea-build-utils/{npm-packages,targets}.mts - util/{changed-test-mapper,patches,socket-btm-releases}.mts
1 parent 12dba1a commit d2cab0c

22 files changed

Lines changed: 63 additions & 63 deletions

packages/cli/scripts/build-sea.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const logger = getDefaultLogger()
3535
/**
3636
* Filter targets based on CLI arguments.
3737
*/
38-
export function filterTargets(targets, options) {
38+
function filterTargets(targets, options) {
3939
if (options.all) {
4040
return targets
4141
}

packages/cli/scripts/build.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const printError = msg => {
5050
* @param {boolean} options.quiet - Suppress output.
5151
* @param {boolean} options.verbose - Show detailed output.
5252
*/
53-
export async function fixNodeGypStrings(dir, options = {}) {
53+
async function fixNodeGypStrings(dir, options = {}) {
5454
const { quiet = false, verbose = false } = options
5555

5656
// Find all .js files in build directory.

packages/cli/scripts/constants/build.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
*/
44

55
// Build configuration file names.
6-
export const BIOME_JSON = 'biome.json'
7-
export const TSCONFIG_JSON = 'tsconfig.json'
6+
const BIOME_JSON = 'biome.json'
7+
const TSCONFIG_JSON = 'tsconfig.json'
88

99
// Rollup configuration.
10-
export const ROLLUP_EXTERNAL_SUFFIX = '?commonjs-external'
10+
const ROLLUP_EXTERNAL_SUFFIX = '?commonjs-external'
1111

1212
// Encoding constants.
1313
export const UTF8 = 'utf8'

packages/cli/scripts/constants/external-tools-platforms.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const PLATFORM_MAP_TOOLS = {
167167
*
168168
* @returns {string} Normalized platform key (e.g., 'win-x64').
169169
*/
170-
export function getPlatformKey(platform, arch) {
170+
function getPlatformKey(platform, arch) {
171171
const releasePlatform = platform === 'win32' ? 'win' : platform
172172
return `${releasePlatform}-${arch}`
173173
}

packages/cli/scripts/constants/packages.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ export const SOCKET_CLI_SENTRY_PNPM_BIN_NAME = 'socket-pnpm-with-sentry'
2424
export const SOCKET_CLI_SENTRY_YARN_BIN_NAME = 'socket-yarn-with-sentry'
2525

2626
// File and directory names from registry.
27-
export const GITIGNORE = '.gitignore'
27+
const GITIGNORE = '.gitignore'
2828
export const NODE_MODULES = 'node_modules'
2929
export const PACKAGE_JSON = 'package.json'
3030
export const PNPM_LOCK_YAML = 'pnpm-lock.yaml'
3131
export const SOCKET_REGISTRY_PACKAGE_NAME = '@socketsecurity/registry-stable'
3232

3333
// Path separators.
34-
export const SLASH_NODE_MODULES_SLASH = '/node_modules/'
34+
const SLASH_NODE_MODULES_SLASH = '/node_modules/'

packages/cli/scripts/constants/paths.mts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,31 @@ export const externalPath = path.join(rootPath, 'external')
2323
export const srcPath = path.join(rootPath, 'src')
2424

2525
// Package and lockfile paths.
26-
export const rootPackageJsonPath = path.join(rootPath, PACKAGE_JSON)
27-
export const rootPackageLockPath = path.join(rootPath, PNPM_LOCK_YAML)
26+
const rootPackageJsonPath = path.join(rootPath, PACKAGE_JSON)
27+
const rootPackageLockPath = path.join(rootPath, PNPM_LOCK_YAML)
2828
export const rootNodeModulesBinPath = path.join(rootPath, NODE_MODULES, '.bin')
2929

3030
// Socket registry path (in external, not dist).
31-
export const socketRegistryPath = path.join(
31+
const socketRegistryPath = path.join(
3232
externalPath,
3333
SOCKET_REGISTRY_PACKAGE_NAME,
3434
)
3535

3636
// Cache directory paths.
37-
export const SOCKET_CACHE_DIR = path.join(homedir(), '.socket')
37+
const SOCKET_CACHE_DIR = path.join(homedir(), '.socket')
3838
export const SOCKET_CLI_SEA_BUILD_DIR = path.join(
3939
tmpdir(),
4040
'socket-cli-sea-build',
4141
)
42-
export const SOCKET_CLI_SEA_BUILD_DIR_FALLBACK = '/tmp/socket-cli-sea-build'
42+
const SOCKET_CLI_SEA_BUILD_DIR_FALLBACK = '/tmp/socket-cli-sea-build'
4343

4444
// Directory name constant.
45-
export const CONSTANTS = 'constants'
45+
const CONSTANTS = 'constants'
4646

4747
/**
4848
* Get all global cache directories.
4949
*/
50-
export function getGlobalCacheDirs() {
50+
function getGlobalCacheDirs() {
5151
return [
5252
{ name: '~/.socket', path: SOCKET_CACHE_DIR },
5353
{ name: '$TMPDIR/socket-cli-sea-build', path: SOCKET_CLI_SEA_BUILD_DIR },

packages/cli/scripts/download-assets.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ async function downloadAssets(assetNames, parallel = true) {
172172
/**
173173
* Extract tar.gz archive.
174174
*/
175-
export async function extractArchive(tarGzPath, extractConfig, assetName) {
175+
async function extractArchive(tarGzPath, extractConfig, assetName) {
176176
const { outputDir } = extractConfig
177177

178178
await fs.mkdir(outputDir, { recursive: true })

packages/cli/scripts/esbuild-utils.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function createBaseConfig(
4848
* Helper to create both dot and bracket notation define keys. This ensures
4949
* esbuild can replace both forms of process.env access.
5050
*/
51-
export function createDefineEntries(envVars: Record<string, string>) {
51+
function createDefineEntries(envVars: Record<string, string>) {
5252
const entries: Record<string, string> = {}
5353
// oxlint-disable-next-line socket/prefer-cached-for-loop -- loop variable is destructured
5454
for (const [key, value] of Object.entries(envVars)) {

packages/cli/scripts/paths.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url'
55
import { existsSync } from 'node:fs'
66

77
/* oxlint-disable-next-line socket/sort-source-methods -- helper used by PACKAGE_ROOT below. */
8-
export function resolvePackageRoot(): string {
8+
function resolvePackageRoot(): string {
99
let cur = path.dirname(fileURLToPath(import.meta.url))
1010
const root = path.parse(cur).root
1111
while (cur && cur !== root) {

packages/cli/scripts/restore-cache.mts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const isVerbose = () => process.argv.includes('--verbose')
3535
/**
3636
* Check if cache exists in GitHub Actions.
3737
*/
38-
export async function cacheExists(repo, cacheKey) {
38+
async function cacheExists(repo, cacheKey) {
3939
try {
4040
const result = await spawn(
4141
'gh',
@@ -73,7 +73,7 @@ export async function cacheExists(repo, cacheKey) {
7373
/**
7474
* Generate CLI build cache key (matches CI workflow).
7575
*/
76-
export async function generateCacheKey() {
76+
async function generateCacheKey() {
7777
const pnpmLockHash = await hashFile(path.join(repoRoot, 'pnpm-lock.yaml'))
7878
const srcHash = await hashFiles('packages/cli/src', repoRoot)
7979
const configHash = await hashFiles(
@@ -87,7 +87,7 @@ export async function generateCacheKey() {
8787
/**
8888
* Get current git commit SHA.
8989
*/
90-
export async function getCurrentCommit() {
90+
async function getCurrentCommit() {
9191
try {
9292
const result = await spawn('git', ['rev-parse', 'HEAD'], {
9393
cwd: repoRoot,
@@ -105,7 +105,7 @@ export async function getCurrentCommit() {
105105
/**
106106
* Check if gh CLI is available.
107107
*/
108-
export async function hasGhCli() {
108+
async function hasGhCli() {
109109
try {
110110
const result = await spawn('gh', ['--version'], {
111111
stdio: 'pipe',
@@ -119,7 +119,7 @@ export async function hasGhCli() {
119119
/**
120120
* Compute hash of file.
121121
*/
122-
export async function hashFile(filePath) {
122+
async function hashFile(filePath) {
123123
try {
124124
const content = await fs.readFile(filePath, 'utf8')
125125
return createHash('sha256').update(content).digest('hex')
@@ -131,7 +131,7 @@ export async function hashFile(filePath) {
131131
/**
132132
* Compute hash of all files matching glob pattern.
133133
*/
134-
export async function hashFiles(globPattern, cwd) {
134+
async function hashFiles(globPattern, cwd) {
135135
try {
136136
const result = await spawn(
137137
'find',
@@ -177,7 +177,7 @@ export async function hashFiles(globPattern, cwd) {
177177
/**
178178
* Download and extract cache from GitHub Actions.
179179
*/
180-
export async function restoreCache(repo, cacheKey) {
180+
async function restoreCache(repo, cacheKey) {
181181
const tempDir = path.join(packageRoot, 'node_modules', '.cache', 'restore')
182182
await fs.mkdir(tempDir, { recursive: true })
183183

0 commit comments

Comments
 (0)