@@ -7,8 +7,13 @@ const examplesDir = path.resolve(import.meta.dirname, "../examples");
77
88type Mode = "development" | "production" ;
99
10+ interface PackageJson {
11+ dependencies : Record < string , string > ;
12+ devDependencies : Record < string , string > ;
13+ }
14+
1015// Hardcoded catalogs matching pnpm-workspace.yaml
11- const CATALOGS = {
16+ const catalogs = {
1217 react19 : {
1318 "@types/react" : "~19.1.13" ,
1419 "@types/react-dom" : "~19.1.9" ,
@@ -20,14 +25,16 @@ const CATALOGS = {
2025// Function to toggle the mode for a single example
2126const toggleMode = ( examplePath : string , mode : Mode ) : void => {
2227 const packageJsonPath = path . join ( examplePath , "package.json" ) ;
23- const packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , "utf-8" ) ) ;
28+ const packageJson = JSON . parse (
29+ fs . readFileSync ( packageJsonPath , "utf-8" ) ,
30+ ) as PackageJson ;
2431
2532 // Toggle @evolu /* dependencies
2633 for ( const dep in packageJson . dependencies ) {
2734 if ( dep . startsWith ( "@evolu/" ) ) {
2835 if ( mode === "production" ) {
2936 packageJson . dependencies [ dep ] = `latest` ;
30- } else if ( mode === "development" ) {
37+ } else {
3138 packageJson . dependencies [ dep ] = `workspace:*` ;
3239 }
3340 }
@@ -39,13 +46,14 @@ const toggleMode = (examplePath: string, mode: Mode): void => {
3946 const value = deps [ dep ] ;
4047 if ( mode === "production" && value . startsWith ( "catalog:" ) ) {
4148 const catalogName = value . replace ( "catalog:" , "" ) ;
42- const catalog = CATALOGS [ catalogName as keyof typeof CATALOGS ] ;
49+ const catalog = catalogs [ catalogName as keyof typeof catalogs ] ;
50+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
4351 if ( catalog && dep in catalog ) {
4452 deps [ dep ] = catalog [ dep as keyof typeof catalog ] ;
4553 }
4654 } else if ( mode === "development" ) {
4755 // Find which catalog this dep belongs to
48- for ( const [ catalogName , catalogDeps ] of Object . entries ( CATALOGS ) ) {
56+ for ( const [ catalogName , catalogDeps ] of Object . entries ( catalogs ) ) {
4957 if (
5058 dep in catalogDeps &&
5159 catalogDeps [ dep as keyof typeof catalogDeps ] === value
@@ -80,6 +88,7 @@ const toggleAllExamples = (targetMode: Mode): void => {
8088
8189 execSync ( "pnpm clean" , { stdio : "inherit" } ) ;
8290 execSync ( "pnpm i" , { stdio : "inherit" } ) ;
91+ // eslint-disable-next-line no-console
8392 console . log ( `All examples switched to ${ targetMode } mode.` ) ;
8493} ;
8594
@@ -108,16 +117,20 @@ const askForModeInteractive = async (): Promise<Mode> => {
108117 const question =
109118 "Which mode do you want to switch to? (1) development (2) production: " ;
110119 const prompt = ( ) : Promise < string > =>
111- new Promise ( ( resolve ) => rl . question ( question , resolve ) ) ;
120+ new Promise ( ( resolve ) => {
121+ rl . question ( question , resolve ) ;
122+ } ) ;
112123
113124 // Keep prompting until valid answer
125+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
114126 while ( true ) {
115127 const answer = ( await prompt ( ) ) . trim ( ) ;
116128 const mode = parseModeString ( answer ) ;
117129 if ( mode ) {
118130 rl . close ( ) ;
119131 return mode ;
120132 }
133+ // eslint-disable-next-line no-console
121134 console . log (
122135 "Invalid option — please reply with 1 or 2 (or 'development'/'production')." ,
123136 ) ;
@@ -129,7 +142,7 @@ const main = async () => {
129142 toggleAllExamples ( mode ) ;
130143} ;
131144
132- // Run the main function
133- main ( ) . catch ( ( error ) => {
145+ main ( ) . catch ( ( error : unknown ) => {
146+ // eslint-disable-next-line no-console
134147 console . error ( "Error:" , error ) ;
135148} ) ;
0 commit comments