@ohos-ports/react-native-navigation 8.9.0-beta.10 → 8.9.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +5 -1
- package/postinstall.js +53 -0
package/README.md
CHANGED
|
@@ -8,17 +8,17 @@ React Native Navigation — truly native navigation for iOS and Android, ported
|
|
|
8
8
|
npm install @ohos-ports/react-native-navigation @ohos-ports/react-native react
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The `react-native` overrides (mapping all `react-native` references to `@ohos-ports/react-native`) are **automatically configured** by the package's postinstall script. If the script does not run (e.g. install scripts are disabled), add this to your project's `package.json` manually:
|
|
12
12
|
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
15
15
|
"overrides": {
|
|
16
|
-
"react-native": "npm:@ohos-ports/react-native@^0.87.1-beta.
|
|
16
|
+
"react-native": "npm:@ohos-ports/react-native@^0.87.1-beta.2"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
This ensures that all `react-native` references (including transitive dependencies) resolve to `@ohos-ports/react-native`, preventing the original Facebook `react-native` (with Flow syntax) from being installed.
|
|
22
22
|
|
|
23
23
|
## Requirements
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/react-native-navigation",
|
|
3
|
-
"version": "8.9.0-beta.
|
|
3
|
+
"version": "8.9.0-beta.12",
|
|
4
4
|
"description": "React Native Navigation - truly native navigation for iOS and Android (HarmonyOS port)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,9 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"lib",
|
|
33
|
+
"postinstall.js",
|
|
33
34
|
"README.md",
|
|
34
35
|
"LICENSE"
|
|
35
36
|
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"postinstall": "node postinstall.js"
|
|
39
|
+
},
|
|
36
40
|
"peerDependencies": {
|
|
37
41
|
"react": "*"
|
|
38
42
|
},
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const REQUIRED_OVERRIDE = "npm:@ohos-ports/react-native@^0.87.1-beta.2";
|
|
7
|
+
|
|
8
|
+
// npm sets INIT_CWD to the project root during postinstall
|
|
9
|
+
const projectRoot = process.env.INIT_CWD || process.cwd();
|
|
10
|
+
const pkgPath = path.join(projectRoot, "package.json");
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(pkgPath)) {
|
|
13
|
+
// Not a project context (e.g. running inside the package's own dir), skip
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let pkg;
|
|
18
|
+
try {
|
|
19
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
20
|
+
} catch {
|
|
21
|
+
// Invalid package.json, skip silently
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Check if override already exists and matches
|
|
26
|
+
const existing = pkg.overrides && pkg.overrides["react-native"];
|
|
27
|
+
if (existing === REQUIRED_OVERRIDE) {
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Add/update overrides
|
|
32
|
+
if (!pkg.overrides) {
|
|
33
|
+
pkg.overrides = {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pkg.overrides["react-native"] = REQUIRED_OVERRIDE;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
40
|
+
console.log(
|
|
41
|
+
"[@ohos-ports/react-native-navigation] " +
|
|
42
|
+
'Automatically added "overrides.react-native" to your package.json. ' +
|
|
43
|
+
"Please run `npm install` again to apply the changes."
|
|
44
|
+
);
|
|
45
|
+
} catch {
|
|
46
|
+
// Cannot write (read-only filesystem, permissions, etc.) — fall back to warning
|
|
47
|
+
console.warn(
|
|
48
|
+
"[@ohos-ports/react-native-navigation] " +
|
|
49
|
+
"Could not automatically add overrides to package.json. " +
|
|
50
|
+
'Please add this to your package.json manually:\n' +
|
|
51
|
+
JSON.stringify({ overrides: { "react-native": REQUIRED_OVERRIDE } }, null, 2)
|
|
52
|
+
);
|
|
53
|
+
}
|