-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.plugin.js
68 lines (64 loc) · 2.41 KB
/
app.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { withDangerousMod } = require("@expo/config-plugins");
const { execSync } = require("child_process");
const readline = require("readline");
const withRNRenderSwiftUI = (config, { srcDir, noClean, dependencys } = {}) => {
return withDangerousMod(config, [
"ios",
(config) => {
console.log("Running RNSwiftUI preperation");
try {
execSync(
`cp ./node_modules/react-native-render-swift-ui/ios/ReactNativeRenderSwiftUi.podspec.config ./node_modules/react-native-render-swift-ui/ios/ReactNativeRenderSwiftUi.podspec`,
{ stdio: "inherit" }
);
dependencys &&
dependencys.forEach((dependency) => {
if (
dependency !== "Kingfischer" &&
dependency !== "ExpoModulesCore"
)
execSync(
`sed -i '' -e '/# Custom Dependencys/p; s/# Custom Dependencys/s.dependency "${dependency}"/' ./node_modules/react-native-render-swift-ui/ios/ReactNativeRenderSwiftUi.podspec
`,
{ stdio: "inherit" }
);
});
execSync(
`find ./node_modules/react-native-render-swift-ui/ios/CustomViews -type f ! -name 'index.swift' -exec rm -f {} +`,
{ stdio: "inherit" }
);
execSync(
`node ./node_modules/react-native-render-swift-ui/custom.js ${srcDir !== null && srcDir} ${noClean && "--no-clean"} `,
{ stdio: "inherit" }
);
console.log(
"\u001b[1;32m \n✓ The following dependencies have been added to your project: \n" +
" " +
JSON.stringify(dependencys || []) +
"\n"
);
readline
.createInterface({ input: process.stdin, output: process.stdout })
.question("", (answer) => {
answer.trim().toLowerCase() === "yes"
? require("child_process").execSync("cd ios && pod install", {
stdio: "inherit",
})
: console.log(`\u001b[1;33m \n⚠ Pod-Install skipped \n`);
process.exit();
});
setTimeout(
() =>
console.log(
"\nDo you want to run pod install in the ios directory? (yes/no)"
),
1000
);
} catch (error) {
console.error("Error running rn-render-swift-ui preparation:", error);
}
return config;
},
]);
};
module.exports = withRNRenderSwiftUI;