1313// reset labels. `--before` swaps in subscriptionUsageSnapshot.ts from the
1414// merge-base so the same hook runs over the pre-fix code. Reload the app
1515// (Metro picks the change up) after each apply.
16- import { execFileSync } from "node:child_process" ;
17- import { existsSync , readFileSync , rmSync , writeFileSync } from "node:fs" ;
18- import { dirname , join } from "node:path" ;
19- import { fileURLToPath } from "node:url" ;
16+ import * as NodeChildProcess from "node:child_process" ;
17+ import * as NodeFS from "node:fs" ;
18+ import * as NodePath from "node:path" ;
19+ import * as NodeURL from "node:url" ;
2020
2121const BEFORE_REF = "8d3b061121fe65669d5d43d011b48cd3027a4108" ;
22- const appRoot = join ( dirname ( fileURLToPath ( import . meta. url ) ) , ".." ) ;
23- const coordinator = join ( appRoot , "src/widgets/SubscriptionUsageCoordinator.tsx" ) ;
24- const snapshotModule = join ( appRoot , "src/widgets/subscriptionUsageSnapshot.ts" ) ;
25- const fixtureModule = join ( appRoot , "src/widgets/widgetFixture22973.ts" ) ;
22+ const appRoot = NodePath . join ( NodePath . dirname ( NodeURL . fileURLToPath ( import . meta. url ) ) , ".." ) ;
23+ const coordinator = NodePath . join ( appRoot , "src/widgets/SubscriptionUsageCoordinator.tsx" ) ;
24+ const snapshotModule = NodePath . join ( appRoot , "src/widgets/subscriptionUsageSnapshot.ts" ) ;
25+ const fixtureModule = NodePath . join ( appRoot , "src/widgets/widgetFixture22973.ts" ) ;
2626const tracked = [ coordinator , snapshotModule ] ;
2727
2828const codex = (
@@ -58,26 +58,27 @@ const fixtures: Record<string, string[]> = {
5858 ] ,
5959} ;
6060
61- const git = ( ...args : string [ ] ) => execFileSync ( "git" , args , { cwd : appRoot , encoding : "utf8" } ) ;
61+ const git = ( ...args : string [ ] ) =>
62+ NodeChildProcess . execFileSync ( "git" , args , { cwd : appRoot , encoding : "utf8" } ) ;
6263
6364function revert ( ) {
6465 git ( "checkout" , "HEAD" , "--" , ...tracked ) ;
65- rmSync ( fixtureModule , { force : true } ) ;
66+ NodeFS . rmSync ( fixtureModule , { force : true } ) ;
6667}
6768
6869function apply ( name : string , anchor : number , beforeRef : string | undefined ) {
6970 const providers = fixtures [ name ] ;
7071 if ( ! providers )
7172 throw new Error ( `Unknown fixture ${ name } ; known: ${ Object . keys ( fixtures ) . join ( ", " ) } ` ) ;
72- if ( ! existsSync ( fixtureModule ) && git ( "status" , "--porcelain" , "--" , ...tracked ) . trim ( ) )
73+ if ( ! NodeFS . existsSync ( fixtureModule ) && git ( "status" , "--porcelain" , "--" , ...tracked ) . trim ( ) )
7374 throw new Error ( "Widget sources have uncommitted changes; commit or revert them first." ) ;
7475 revert ( ) ;
7576 if ( beforeRef )
76- writeFileSync (
77+ NodeFS . writeFileSync (
7778 snapshotModule ,
7879 git ( "show" , `${ beforeRef } :apps/mobile/src/widgets/subscriptionUsageSnapshot.ts` ) ,
7980 ) ;
80- writeFileSync (
81+ NodeFS . writeFileSync (
8182 fixtureModule ,
8283 `// Generated by scripts/seed-widget-fixture-22973.mts; removed by its revert command.
8384const ANCHOR = ${ anchor } ; // ${ new Date ( anchor ) . toISOString ( ) }
@@ -97,11 +98,11 @@ export function widgetFixture22973<T>(): T {
9798}
9899` ,
99100 ) ;
100- const source = readFileSync ( coordinator , "utf8" ) ;
101+ const source = NodeFS . readFileSync ( coordinator , "utf8" ) ;
101102 const read = "get(environmentPresentations.presentationsWithProvidersAtom)," ;
102103 if ( ! source . includes ( read ) )
103104 throw new Error ( "SubscriptionUsageCoordinator.tsx no longer matches the hook" ) ;
104- writeFileSync (
105+ NodeFS . writeFileSync (
105106 coordinator ,
106107 source
107108 . replace ( read , `widgetFixture22973<Parameters<typeof buildSubscriptionUsageSnapshot>[0]>(),` )
0 commit comments