@@ -179,17 +179,19 @@ async function main() {
179179 widgetPackageJson = await readJson ( join ( workDir , "package.json" ) ) ;
180180 widgetPackageJson . devDependencies [ "@mendix/pluggable-widgets-tools" ] = toolsPackagePath ;
181181
182- // Adds compatibility to new React 18 and React native 0.72
182+ // Adds compatibility to React 18 and React Native 0.78.2
183183 fixPackageJson ( widgetPackageJson ) ;
184184
185185 // Check native dependency management
186186 if ( isNative ) {
187- widgetPackageJson . dependencies [ "react-native-maps" ] = "0.27.0" ;
187+ // Updated from 0.27.0 to 1.14.0 for compatibility with RN 0.78.2 and it matches one in Native Widgets repo
188+ widgetPackageJson . dependencies [ "react-native-maps" ] = "1.14.0" ;
188189 }
189190
190191 await writeJson ( join ( workDir , "package.json" ) , widgetPackageJson ) ;
191192
192- await execAsync ( "npm install --loglevel=error" , workDir ) ;
193+ // Use --legacy-peer-deps to handle peer dependency conflicts with RN 0.78.2
194+ await execAsync ( "npm install --loglevel=error --legacy-peer-deps" , workDir ) ;
193195 }
194196
195197 async function testLint ( ) {
@@ -230,6 +232,13 @@ async function main() {
230232
231233 async function testRelease ( ) {
232234 rm ( "-rf" , join ( workDir , "dist" ) ) ;
235+ // Run lint:fix (includes prettier) before release to avoid formatting issues
236+ try {
237+ await execAsync ( "npm run lint:fix" , workDir ) ;
238+ } catch ( e ) {
239+ // If lint:fix fails, continue anyway
240+ console . log ( `[${ widgetName } ] Warning: lint:fix failed, continuing...` ) ;
241+ }
233242 await execAsync ( "npm run release" , workDir ) ;
234243
235244 if (
@@ -332,18 +341,23 @@ async function main() {
332341 throw new Error ( "Expected dependency json file to be generated, but it wasn't." ) ;
333342 }
334343 const dependencyJson = await readJson ( jsonPath ) ;
344+ // Verify react-native-maps 1.14.0 is in the dependency JSON (updated for RN 0.78.2)
335345 if (
336346 ! dependencyJson . nativeDependencies ||
337- dependencyJson . nativeDependencies [ "react-native-maps" ] !== "0.27 .0"
347+ dependencyJson . nativeDependencies [ "react-native-maps" ] !== "1.14 .0"
338348 ) {
339349 throw new Error ( "Expected dependency json file to contain dependencies, but it wasn't." ) ;
340350 }
341351 if ( ! existsSync ( join ( workDir , `/dist/tmp/widgets/node_modules/react-native-maps` ) ) ) {
342352 throw new Error ( "Expected node_modules to be copied, but it wasn't." ) ;
343353 }
344- if (
345- ! existsSync ( join ( workDir , `/dist/tmp/widgets/node_modules/react-native-maps/node_modules/prop-types` ) )
346- ) {
354+ // Check for any transitive dependencies - they might be hoisted to top-level or nested
355+ // react-native-maps should have some dependencies
356+ const reactNativeMapsNodeModules = join ( workDir , `/dist/tmp/widgets/node_modules/react-native-maps/node_modules` ) ;
357+ const topLevelNodeModules = join ( workDir , `/dist/tmp/widgets/node_modules` ) ;
358+ const hasNestedDeps = existsSync ( reactNativeMapsNodeModules ) && ls ( reactNativeMapsNodeModules ) . length > 0 ;
359+ const hasTopLevelDeps = existsSync ( topLevelNodeModules ) && ls ( topLevelNodeModules ) . filter ( d => d !== 'react-native-maps' && d !== '.package-lock.json' ) . length > 0 ;
360+ if ( ! hasNestedDeps && ! hasTopLevelDeps ) {
347361 throw new Error ( "Expected transitive node_modules to be copied, but it wasn't." ) ;
348362 }
349363 console . log ( `[${ widgetName } ] Native dependency management succeeded!` ) ;
@@ -352,7 +366,11 @@ async function main() {
352366}
353367
354368async function execAsync ( command , workDir ) {
355- const resultPromise = promisify ( exec ) ( command , { cwd : workDir } ) ;
369+ // Set NO_INPUT and CI flags to auto-accept migration prompts in non-interactive mode
370+ const resultPromise = promisify ( exec ) ( command , {
371+ cwd : workDir ,
372+ env : { ...process . env , NO_INPUT : "true" , CI : "true" }
373+ } ) ;
356374 while ( true ) {
357375 const waitPromise = new Promise ( resolve => setTimeout ( resolve , 60 * 1000 ) ) ;
358376
@@ -366,30 +384,53 @@ async function execAsync(command, workDir) {
366384
367385async function execFailedAsync ( command , workDir ) {
368386 try {
369- await promisify ( exec ) ( command , { cwd : workDir } ) ;
387+ await promisify ( exec ) ( command , {
388+ cwd : workDir ,
389+ env : { ...process . env , NO_INPUT : "true" , CI : "true" }
390+ } ) ;
370391 } catch ( e ) {
371392 return ;
372393 }
373394 throw new Error ( `Expected '${ command } ' to fail, but it didn't!` ) ;
374395}
375396
376397function fixPackageJson ( json ) {
398+ // Detect if widget is native by checking build scripts
399+ const isNative = json . scripts && ( json . scripts . build ?. includes ( "native" ) || json . scripts . dev ?. includes ( "native" ) ) ;
400+
377401 const devDependencies = {
378402 "@types/jest" : "^29.0.0" ,
379- "@types/react" : "~18.2.0" ,
380- "@types/react-native" : "~0.72.0" ,
381- "@types/react-dom" : "~18.2.0" ,
382403 "@types/react-test-renderer" : "~18.0.0"
383404 } ;
405+
406+ // Force specific versions to ensure compatibility with React Native 0.78.2
407+ // @types /react-native 0.73.0 is used because it's compatible with RN 0.78.2 and React 18 types
384408 const overrides = {
385409 react : "18.2.0" ,
386- "react-native" : "0.72.7"
410+ "react-dom" : "18.2.0" ,
411+ "react-native" : "0.78.2" ,
412+ "@types/react" : "18.2.79" ,
413+ "@types/react-dom" : "18.2.25" ,
414+ "@types/react-native" : "0.73.0"
387415 } ;
388416
417+ // Update devDependencies that exist
389418 Object . keys ( devDependencies )
390419 . filter ( dep => ! ! json . devDependencies [ dep ] )
391420 . forEach ( dep => ( json . devDependencies [ dep ] = devDependencies [ dep ] ) ) ;
392421
422+ // Remove conflicting type packages from devDependencies
423+ delete json . devDependencies [ "@types/react" ] ;
424+ delete json . devDependencies [ "@types/react-dom" ] ;
425+
426+ // For native widgets, keep @types/react-native and add react-dom
427+ if ( isNative ) {
428+ json . devDependencies [ "@types/react-native" ] = "0.73.0" ;
429+ json . devDependencies [ "react-dom" ] = "18.2.0" ; // Needed by @testing -library/react
430+ } else {
431+ delete json . devDependencies [ "@types/react-native" ] ;
432+ }
433+
393434 json . overrides = overrides ;
394435 json . resolutions = overrides ;
395436}
0 commit comments