@@ -6,6 +6,7 @@ import process from 'node:process'
66import {
77 SNAPSHOT_DEPENDENCIES ,
88 assertSnapshotDependenciesCurrent ,
9+ normalizeSnapshotDependencyName ,
910} from './snapshot-dependencies.mts'
1011import { isMainModule } from '../lib/is-main-module.mts'
1112import { runMain } from '../lib/run-main.mts'
@@ -31,9 +32,9 @@ export interface SnapshotOptions {
3132function missingSnapshotDependencyError ( ) : Error {
3233 return new Error (
3334 'Provide a dependency name. Usage: pnpm snapshots:update:dep <name>. ' +
34- 'Current example : pnpm snapshots:update:dep coana. ' +
35- 'Partner names to map: socket-patch, socket-python-cli . ' +
36- `Currently mapped: ${ Object . keys ( SNAPSHOT_DEPENDENCIES ) . join ( ', ' ) } .` ,
35+ 'Examples : pnpm snapshots:update:dep coana, pnpm snapshots:update:dep socket-patch, or pnpm snapshots:update:dep patch . ' +
36+ 'Socket Python CLI still needs a snapshot mapping . ' +
37+ `Currently mapped: ${ Object . keys ( SNAPSHOT_DEPENDENCIES ) . join ( ', ' ) } , socket-patch .` ,
3738 )
3839}
3940
@@ -49,9 +50,10 @@ export function parseSnapshotArgs(args: readonly string[]): SnapshotOptions {
4950 if ( ! value ?. trim ( ) ) {
5051 throw missingSnapshotDependencyError ( )
5152 }
52- if ( ! ( value in SNAPSHOT_DEPENDENCIES ) ) {
53+ const normalizedName = normalizeSnapshotDependencyName ( value )
54+ if ( ! normalizedName ) {
5355 throw new Error (
54- `Unknown snapshot dependency: ${ value } ; available: ${ Object . keys ( SNAPSHOT_DEPENDENCIES ) . join ( ', ' ) } ` ,
56+ `Unknown snapshot dependency: ${ value } ; available: coana, socket-patch, patch ` ,
5557 )
5658 }
5759 if ( dependencyName ) {
@@ -75,7 +77,8 @@ export function nativeSnapshotArgs(update: boolean): string[] {
7577export function dependencySnapshotArgs (
7678 dependencyName : SnapshotDependencyName ,
7779) : string [ ] {
78- const config = SNAPSHOT_DEPENDENCIES [ dependencyName ]
80+ const config =
81+ SNAPSHOT_DEPENDENCIES [ normalizeSnapshotDependencyName ( dependencyName ) ! ]
7982 return [
8083 '--build' ,
8184 'test/native/commands/cli.native.test.mts' ,
@@ -165,6 +168,7 @@ export interface SnapshotWorkflowDependencies {
165168 acquireLock ( ) : Promise < void >
166169 releaseLock ( ) : Promise < void >
167170 createArtifactsDir ( ) : Promise < string >
171+ assertDependenciesCurrent ( ) : Promise < void >
168172 runNative ( update : boolean , artifactsDir : string ) : void
169173 runDependencyNative ( dependencyName : SnapshotDependencyName , artifactsDir : string ) : void
170174 runTerminal ( update : boolean , artifactsDir : string ) : void
@@ -198,6 +202,7 @@ const DEFAULT_DEPENDENCIES: SnapshotWorkflowDependencies = {
198202 ) ,
199203 )
200204 } ,
205+ assertDependenciesCurrent : assertSnapshotDependenciesCurrent ,
201206 runNative ( update , artifactsDir ) {
202207 run ( [ 'scripts/test/native.mts' , ...nativeSnapshotArgs ( update ) ] , {
203208 env : { ...process . env , SOCKET_CLI_NATIVE_TEST_ARTIFACTS : artifactsDir } ,
@@ -246,7 +251,7 @@ export async function runSnapshotWorkflow(
246251 dependencies . runDependencyNative ( selectedDependencyName , artifactsDir )
247252 } else {
248253 if ( ! update ) {
249- await assertSnapshotDependenciesCurrent ( )
254+ await dependencies . assertDependenciesCurrent ( )
250255 }
251256 dependencies . runNative ( update , artifactsDir )
252257 dependencies . runTerminal ( update , artifactsDir )
@@ -269,13 +274,13 @@ const SCRIPT_META: ScriptMeta = {
269274 describe : 'builds, runs, and reports native terminal snapshot tests' ,
270275 help : `Usage: pnpm snapshots [--update|-u]
271276 pnpm snapshots:update
272- pnpm snapshots:update:dep <name>
277+ pnpm snapshots:update:dep <name> (coana, socket-patch, patch)
273278
274279 Builds the native CLI, runs the focused terminal screenshot tests, and writes
275280 a self-contained HTML report into a fresh build/native-test-artifacts folder.
276281 Pass --update or -u to update the native screenshot baselines. Use the dep
277282 command to rebuild and update only snapshots affected by a pinned tool, for
278- example: pnpm snapshots:update:dep coana .` ,
283+ example: pnpm snapshots:update:dep socket-patch .` ,
279284}
280285
281286if ( isMainModule ( import . meta. url ) ) {
0 commit comments