Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Fixed
- Directory scans now filter unsupported files before deduplicating matches, reducing memory use in large repositories.

## [1.16.0](https://github.com/SocketDev/socket-cli/releases/tag/v1.16.0) - 2026-11-19

### Added
Expand Down
2 changes: 1 addition & 1 deletion scripts/refresh/snapshots.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type { ScriptMeta } from '../lib/run-main.mts'
import { runMain } from '../lib/run-main.mts'
import type { SnapshotDependencyName } from './snapshots/dependencies.mts'
import {
SNAPSHOT_DEPENDENCIES,
assertSnapshotDependenciesCurrent,
normalizeSnapshotDependencyName,
SNAPSHOT_DEPENDENCIES,
} from './snapshots/dependencies.mts'

const ROOT = path.resolve(import.meta.dirname, '../..')
Expand Down
11 changes: 6 additions & 5 deletions scripts/test/native.mts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SEA_VERSION } from '../../src/sea/version.mts'

import type { SpawnSyncOptions } from 'node:child_process'
import { spawnSync } from 'node:child_process'
import { createHash } from 'node:crypto'
Expand Down Expand Up @@ -25,7 +27,6 @@ const ROOT = path.resolve(import.meta.dirname, '../..')
const PACKAGE_PATH = path.join(ROOT, 'package.json')
type PackageMetadata = {
name: string
version: string
}
const BUILD_DIR = path.join(ROOT, 'build/sea')
const TRIPLE = `${process.platform === 'win32' ? 'win' : process.platform}-${process.arch}`
Expand Down Expand Up @@ -72,10 +73,10 @@ async function verifyArtifact(
const manifest = JSON.parse(manifestText) as NativeManifest
if (
manifest.application?.name !== packageInfo.name ||
manifest.application?.version !== packageInfo.version
manifest.application?.version !== SEA_VERSION
) {
throw new Error(
`Native manifest is for ${manifest.application?.name}@${manifest.application?.version}; expected ${packageInfo.name}@${packageInfo.version}`,
`Native manifest is for ${manifest.application?.name}@${manifest.application?.version}; expected ${packageInfo.name}@${SEA_VERSION}`,
)
}
if (manifest.target?.triple !== TRIPLE) {
Expand Down Expand Up @@ -229,7 +230,7 @@ async function main(): Promise<number> {
process.env['SOCKET_CLI_NATIVE_TEST_STAGE'] = stageDir
process.env['SOCKET_CLI_NATIVE_TEST_CAPABILITIES'] =
manifest.capabilities.available.join(',')
process.env['SOCKET_CLI_NATIVE_TEST_VERSION'] = packageInfo.version
process.env['SOCKET_CLI_NATIVE_TEST_VERSION'] = SEA_VERSION
const nodeRuntime = manifest.payloads.find(
payload => payload.id === 'node-runtime',
)
Expand Down Expand Up @@ -292,7 +293,7 @@ async function main(): Promise<number> {
}
if (
version.status !== 0 ||
!version.stdout.trim().startsWith(packageInfo.version)
!version.stdout.trim().startsWith(SEA_VERSION)
) {
throw new Error(
`Native --version check failed (status ${version.status}): ${version.stdout}${version.stderr}`,
Expand Down
1 change: 1 addition & 0 deletions src/commands/manifest/cmd-manifest-cdxgen.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('socket manifest cdxgen', async () => {
'`socket manifest cdxgen`',
)
},
{ timeout: 60_000 },
)

it.skipIf(process.platform === 'win32')(
Expand Down
9 changes: 6 additions & 3 deletions src/utils/glob.mts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ export async function globWithGitIgnore(
]
: [...ignores, ...cliMinimatchIgnores].map(stripTrailingSlash),
...additionalOptions,
// fast-glob's uniqueness set retains every match before the streaming
// filter runs. Filtered scans deduplicate only supported paths below.
unique: filter ? false : additionalOptions.unique,
// Skip dirs the running user cannot read instead of aborting on the first
// `EACCES`. Pinned after `...additionalOptions` so a caller's options bag
// cannot flip it off; it is a safety invariant, not a tunable.
Expand Down Expand Up @@ -483,7 +486,7 @@ export async function globWithGitIgnore(
// optional caller filter drops non-matches before they accumulate. On the slow
// path each surviving entry is also re-checked against its gitignore ancestor
// chain, which carries the full negation support fast-glob lacks.
const results: string[] = []
const results = new Set<string>()
const stream = fastGlob.globStream(
patterns as string[],
globOptions,
Expand All @@ -502,9 +505,9 @@ export async function globWithGitIgnore(
if (filter && !filter(p)) {
continue
}
results.push(p)
results.add(p)
}
return results
return [...results]
}

export async function globWorkspace(
Expand Down
40 changes: 39 additions & 1 deletion src/utils/glob.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
import os from 'node:os'
import path from 'node:path'

import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import fastGlob from 'fast-glob'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

import { normalizePath } from '@socketsecurity/registry/lib/path'

Expand Down Expand Up @@ -170,6 +171,43 @@ describe('glob utilities', () => {
])
})

it('disables fast-glob uniqueness when filtering', async () => {
mockTestFs({ [`${mockFixturePath}/package.json`]: '{}' })
const globStreamSpy = vi.spyOn(fastGlob, 'globStream')

try {
await globWithGitIgnore(['**/*'], {
cwd: mockFixturePath,
filter: filterJsonFiles,
})

expect(globStreamSpy).toHaveBeenLastCalledWith(
['**/*'],
expect.objectContaining({ unique: false }),
)
} finally {
globStreamSpy.mockRestore()
}
})

it('deduplicates overlapping matches after filtering', async () => {
mockTestFs({
[`${mockFixturePath}/package.json`]: '{}',
[`${mockFixturePath}/src/package.json`]: '{}',
[`${mockFixturePath}/src/readme.md`]: '',
})

const results = await globWithGitIgnore(['**/*.json', 'src/**/*'], {
cwd: mockFixturePath,
filter: filterJsonFiles,
})

expect(results.map(normalizePath).sort()).toEqual([
`${mockFixturePath}/package.json`,
`${mockFixturePath}/src/package.json`,
])
})

it('should skip directories ignored via trailing-slash patterns', async () => {
// fast-glob silently drops `ignore` entries that end in `/`, so
// the pattern produced for `dist/` (`**/dist/`) used to do
Expand Down
25 changes: 12 additions & 13 deletions test/release-workflow.test.mts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { execFileSync } from 'node:child_process'
import {
mkdtempSync,
readFileSync,
rmSync,
writeFileSync,
} from 'node:fs'
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import path from 'node:path'

Expand Down Expand Up @@ -153,9 +148,7 @@ describe('v1 release workflow contract', () => {
const stage = workflow.jobs.publish.steps.find(
step => step.name === 'Stage release packages',
)
const parser = stage?.run
?.split("<<'NODE'\n")[1]
?.split('\nNODE')[0]
const parser = stage?.run?.split("<<'NODE'\n")[1]?.split('\nNODE')[0]
expect(parser).toBeDefined()

const directory = mkdtempSync(path.join(tmpdir(), 'npm-stage-output-'))
Expand Down Expand Up @@ -221,7 +214,9 @@ describe('v1 release workflow contract', () => {
expect(checkIndex).toBeGreaterThanOrEqual(0)
expect(finalizeIndex).toBeGreaterThan(checkIndex)
expect(finalize?.run).toContain('make_latest=false')
expect(finalize?.run).toContain('gh release view "${TAG}" --json databaseId')
expect(finalize?.run).toContain(
'gh release view "${TAG}" --json databaseId',
)
expect(finalize?.run).not.toContain('releases/tags/${TAG}')
})

Expand Down Expand Up @@ -261,9 +256,13 @@ describe('v1 release workflow contract', () => {

const manifest = JSON.parse(
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
) as { publishConfig?: { tag?: string }; version?: string }
expect(manifest.version).toMatch(/^2\.1\.0-rc\.\d+$/u)
expect(manifest.publishConfig?.tag).toBe('rc-2.1.0')
) as { publishConfig?: { tag?: string } }
const releasePolicy = JSON.parse(
readFileSync(new URL('../.config/release.json', import.meta.url), 'utf8'),
) as { identifier: string; versionHint: string }
expect(manifest.publishConfig?.tag).toBe(
`${releasePolicy.identifier}-${releasePolicy.versionHint}`,
)
expect(workflow.on.workflow_dispatch.inputs['release-major']?.default).toBe(
'1',
)
Expand Down
Loading