Skip to content

Commit bc9f2f8

Browse files
committed
Update RN version to 0.78.2
1 parent 1d1954f commit bc9f2f8

12 files changed

Lines changed: 149 additions & 154 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"colors": "1.4.0",
99
"react": "^18.2.0",
1010
"react-dom": "^18.2.0",
11-
"react-native": "~0.77.3"
11+
"react-native": "0.78.2"
1212
},
1313
"license": "Apache-2.0",
1414
"copyright": "© Mendix Technology BV 2022. All rights reserved.",

packages/command-tests/commands.js

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

354368
async 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

367385
async 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

376397
function 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
}

packages/generator-widget/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1818

1919
### Changed
2020

21-
- We upgraded React Native to version 0.77.3 for generated widgets.
21+
- We upgraded React Native to version 0.78.2 for generated widgets.
2222

2323
- We updated the required Node.js version to 20 or newer for the generator and generated widget projects.
2424

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-js-unit.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
},
3535
"resolutions": {
3636
"react": "^18.2.0",
37-
"react-native": "0.77.3"
37+
"react-native": "0.78.2"
3838
},
3939
"overrides": {
4040
"react": "^18.2.0",
41-
"react-native": "0.77.3"
41+
"react-native": "0.78.2"
4242
}
4343
}

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-js.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
},
3030
"resolutions": {
3131
"react": "^18.2.0",
32-
"react-native": "0.77.3"
32+
"react-native": "0.78.2"
3333
},
3434
"overrides": {
3535
"react": "^18.2.0",
36-
"react-native": "0.77.3"
36+
"react-native": "0.78.2"
3737
}
3838
}

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-ts-unit.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"resolutions": {
3838
"react": "^18.2.0",
3939
"@types/react": "^18.2.0",
40-
"react-native": "0.77.3"
40+
"react-native": "0.78.2"
4141
},
4242
"overrides": {
4343
"react": "^18.2.0",
4444
"@types/react": "^18.2.0",
45-
"react-native": "0.77.3"
45+
"react-native": "0.78.2"
4646
}
4747
}

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-ts.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
"resolutions": {
3232
"react": "^18.2.0",
3333
"@types/react": "^18.2.0",
34-
"react-native": "0.77.3"
34+
"react-native": "0.78.2"
3535
},
3636
"overrides": {
3737
"react": "^18.2.0",
3838
"@types/react": "^18.2.0",
39-
"react-native": "0.77.3"
39+
"react-native": "0.78.2"
4040
}
4141
}

packages/generator-widget/generators/app/templates/packages/package_native.json.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"resolutions": {
3838
"react": "^18.2.0",<% if (isLanguageTS) { %>
3939
"@types/react": "^18.2.0",<% } %>
40-
"react-native": "0.77.3"
40+
"react-native": "0.78.2"
4141
},
4242
"overrides": {
4343
"react": "^18.2.0",<% if (isLanguageTS) { %>
4444
"@types/react": "^18.2.0",<% } %>
45-
"react-native": "0.77.3"
45+
"react-native": "0.78.2"
4646
}
4747
}

packages/pluggable-widgets-tools/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2828

2929
- We migrated to pnpm as our package manager. Users of the widgets tools should be able to continue using their package manager of choice.
3030

31-
- We updated React Native to version 0.77.3 to align with the Native Widgets project requirements.
31+
- We updated React Native to version 0.78.2 to align with the Native Widgets project requirements.
3232

3333
- We updated Jest configuration for React Native testing to use the recommended preset and removed Enzyme support for improved compatibility and performance.
3434

packages/pluggable-widgets-tools/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@babel/plugin-transform-react-jsx": "^7.25.9",
3232
"@babel/preset-env": "^7.26.0",
3333
"@babel/preset-react": "^7.25.9",
34-
"@react-native/babel-preset": "0.77.3",
34+
"@react-native/babel-preset": "0.78.2",
3535
"@prettier/plugin-xml": "^1.2.0",
3636
"@rollup/plugin-alias": "^5.1.1",
3737
"@rollup/plugin-babel": "^6.0.4",
@@ -113,7 +113,7 @@
113113
"async-mutex": "^0.2.4",
114114
"react": "^18.2.0",
115115
"react-dom": "^18.2.0",
116-
"react-native": "~0.77.3",
116+
"react-native": "0.78.2",
117117
"tree-kill": "^1.2.2",
118118
"yeoman-test": "^6.2.0"
119119
},

0 commit comments

Comments
 (0)