react-native-secreton 1.0.0 → 2.0.0
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 +47 -21
- package/package.json +4 -3
- package/react-native-secreton.podspec +1 -1
- package/scripts/secreton-ios.sh +35 -0
package/README.md
CHANGED
|
@@ -12,33 +12,59 @@ Command line random key:
|
|
|
12
12
|
openssl rand -hex 32
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Setup
|
|
16
|
+
Link the library:
|
|
17
|
+
```
|
|
18
|
+
$ react-native link react-native-config
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- Manual Link (Android)
|
|
22
|
+
|
|
23
|
+
**android/settings.gradle**
|
|
24
|
+
```diff
|
|
25
|
+
+ include ':react-native-secreton'
|
|
26
|
+
+ project(':react-native-secreton').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-secreton/android')
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**android/app/build.gradle**
|
|
30
|
+
|
|
31
|
+
```diff
|
|
32
|
+
+ apply from: new File(rootProject.projectDir.parentFile.parentFile, "android/secreton.gradle")
|
|
33
|
+
+ loadEnvFromSecretonCliSync(project)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Manual Link (iOS / macOS)
|
|
38
|
+
```diff
|
|
39
|
+
+ pod 'react-native-secreton', :path => '../node_modules/react-native-secreton'
|
|
40
|
+
```
|
|
41
|
+
|
|
15
42
|
## Native Usage
|
|
16
43
|
|
|
17
44
|
### Android
|
|
18
|
-
Config **android/app/build.gradle**
|
|
19
45
|
```groovy
|
|
20
|
-
|
|
21
|
-
apply from: new File(rootProject.projectDir.parentFile.parentFile, "android/secreton.gradle")
|
|
22
|
-
loadEnvFromSecretonCliSync(project)
|
|
23
|
-
...
|
|
24
|
-
react {
|
|
25
|
-
...
|
|
26
|
-
nodeExecutableAndArgs = [
|
|
27
|
-
project.findProperty("NODE_BINARY") ?: "/usr/local/bin/node"
|
|
28
|
-
]
|
|
29
|
-
...
|
|
30
|
-
}
|
|
31
|
-
android {
|
|
32
|
-
defaultConfig {
|
|
33
|
-
manifestPlaceholders = [
|
|
34
|
-
geoApiKey : project.ext.env?.get('GEO_APK_API_KEY')
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
46
|
+
project.ext.env?.get('API_KEY')
|
|
38
47
|
```
|
|
39
48
|
|
|
40
49
|
### iOS / macOS
|
|
41
|
-
|
|
50
|
+
1. Include xcconfig in the project
|
|
51
|
+
|
|
52
|
+
project.pbxproj or Podfile, add:
|
|
53
|
+
```ruby
|
|
54
|
+
ENVFILE = File.join("..", "..", ".env")
|
|
55
|
+
generated = File.join("..", "Secreton.xcconfig")
|
|
42
56
|
```
|
|
43
|
-
|
|
57
|
+
|
|
58
|
+
Then in Xcode build settings:
|
|
59
|
+
```code
|
|
60
|
+
#include? "Secreton.xcconfig"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. Use on native iOS (Objective‑C/Swift)
|
|
64
|
+
```objective‑c
|
|
65
|
+
let apiKey = ProcessInfo.processInfo.environment["GEO_APK_API_KEY"]
|
|
66
|
+
|
|
67
|
+
or
|
|
68
|
+
|
|
69
|
+
let apiKey = Bundle.main.object(forInfoDictionaryKey: "GEO_APK_API_KEY") as? String
|
|
44
70
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-secreton",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Config secret variables for React Native apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"android",
|
|
27
27
|
"ios",
|
|
28
28
|
"cpp",
|
|
29
|
+
"scripts",
|
|
29
30
|
"*.podspec",
|
|
30
31
|
"react-native.config.js",
|
|
31
32
|
"!ios/build",
|
|
@@ -42,8 +43,8 @@
|
|
|
42
43
|
"type": "module",
|
|
43
44
|
"scripts": {
|
|
44
45
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib dist",
|
|
45
|
-
"build
|
|
46
|
-
"prepare": "bob build && npm run build
|
|
46
|
+
"build": "tsc -p tsconfig.cli.json",
|
|
47
|
+
"prepare": "bob build && npm run build",
|
|
47
48
|
"nitrogen": "nitrogen",
|
|
48
49
|
"typecheck": "tsc",
|
|
49
50
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
|
|
20
20
|
s.script_phase = {
|
|
21
21
|
:name => 'Secreton Env',
|
|
22
|
-
:script =>
|
|
22
|
+
:script => 'bash "${PODS_TARGET_SRCROOT}/../../scripts/secreton-ios.sh"',
|
|
23
23
|
:execution_position => :before_compile
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
echo "🚀 [Secreton] iOS script phase running..."
|
|
5
|
+
|
|
6
|
+
WORKSPACE_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
7
|
+
ENVFILE="${ENVFILE:-.env}"
|
|
8
|
+
CLI_BIN="$WORKSPACE_ROOT/node_modules/.bin/rn-secreton-cli"
|
|
9
|
+
GENERATED_FILE="$WORKSPACE_ROOT/Secreton.xcconfig"
|
|
10
|
+
|
|
11
|
+
if [ ! -f "$WORKSPACE_ROOT/$ENVFILE" ]; then
|
|
12
|
+
echo "❌ ENV file not found: $WORKSPACE_ROOT/$ENVFILE"
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if [ ! -f "$CLI_BIN" ]; then
|
|
17
|
+
echo "❌ rn-secreton-cli not found at $CLI_BIN"
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
echo "🔐 rn-secreton generating env (iOS)..."
|
|
22
|
+
: "${ENV_SECRET_KEY:?❌ ENV_SECRET_KEY not set}"
|
|
23
|
+
|
|
24
|
+
"$CLI_BIN" "$WORKSPACE_ROOT/$ENVFILE" --out "$GENERATED_FILE"
|
|
25
|
+
|
|
26
|
+
if [ ! -f "$GENERATED_FILE" ]; then
|
|
27
|
+
echo "// Generated by rn-secreton-cli" > "$GENERATED_FILE"
|
|
28
|
+
while IFS='=' read -r key value; do
|
|
29
|
+
[ -z "$key" ] && continue
|
|
30
|
+
[[ "$key" =~ ^# ]] && continue
|
|
31
|
+
echo "$key=$value" >> "$GENERATED_FILE"
|
|
32
|
+
done < "$WORKSPACE_ROOT/$ENVFILE"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
echo "✅ Secreton.xcconfig generated at $GENERATED_FILE"
|