forked from kingstinct/react-native-device-activity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-workflow.sh
More file actions
executable file
·183 lines (146 loc) · 5.72 KB
/
dev-workflow.sh
File metadata and controls
executable file
·183 lines (146 loc) · 5.72 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
# Development workflow script for react-native-device-activity
# Usage: ./scripts/dev-workflow.sh [command]
set -e
COMMAND=${1:-help}
case $COMMAND in
"setup")
echo "🔧 Setting up development environment..."
# Install dependencies in the library package
echo "📦 Installing library dependencies..."
cd packages/react-native-device-activity
npm install
cd ../..
# Install root dependencies
echo "📦 Installing root dependencies..."
bun install
echo "✅ Development environment ready!"
echo ""
echo "Next steps:"
echo " 1. Make changes in packages/react-native-device-activity/"
echo " 2. Run './scripts/dev-workflow.sh build' to build"
echo " 3. Run './scripts/dev-workflow.sh sync' to sync changes to root"
echo " 4. Test in example app or consuming project"
;;
"build")
echo "🔨 Building library..."
cd packages/react-native-device-activity
npm run build
cd ../..
echo "✅ Library built successfully!"
;;
"sync")
echo "🔄 Syncing library changes to root level..."
# Get the current version from the library package.json
LIBRARY_VERSION=$(node -p "require('./packages/react-native-device-activity/package.json').version")
echo "📋 Library version: $LIBRARY_VERSION"
# Update root package.json version
node -e "
const pkg = require('./package.json');
pkg.version = '$LIBRARY_VERSION';
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
# Copy/update essential files to root
echo " 📁 Copying essential files to root..."
cp packages/react-native-device-activity/app.plugin.js .
cp packages/react-native-device-activity/expo-module.config.json .
# Copy directories (remove and recreate to handle deletions)
echo " 📁 Syncing config-plugin..."
rm -rf config-plugin
cp -r packages/react-native-device-activity/config-plugin .
echo " 📁 Syncing iOS files..."
rm -rf ios
cp -r packages/react-native-device-activity/ios .
echo " 📁 Syncing targets..."
rm -rf targets
cp -r packages/react-native-device-activity/targets .
# Fix app.plugin.js path reference
echo " 🔧 Fixing app.plugin.js path reference..."
sed -i '' 's|require("../../package.json")|require("./package.json")|g' app.plugin.js
echo "✅ Library changes synced to root level!"
;;
"test-example")
echo "🧪 Testing in example app..."
cd apps/example
# Ensure the example app uses the local version
echo " 📝 Updating example app to use local library..."
node -e "
const pkg = require('./package.json');
const libVersion = require('../../packages/react-native-device-activity/package.json').version;
pkg.dependencies['react-native-device-activity'] = libVersion;
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
echo " 📦 Installing example app dependencies..."
npm install
echo " 🔨 Building example app..."
npm run prebuild
echo "✅ Example app ready for testing!"
echo "Run 'cd apps/example && npm run ios' to test on iOS"
;;
"commit")
echo "💾 Committing development changes..."
# Build and sync first
./scripts/dev-workflow.sh build
./scripts/dev-workflow.sh sync
# Stage all changes
git add .
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "ℹ️ No changes to commit"
exit 0
fi
# Get commit message
echo "Enter commit message:"
read -r COMMIT_MESSAGE
if [ -z "$COMMIT_MESSAGE" ]; then
echo "❌ Commit message cannot be empty"
exit 1
fi
git commit -m "$COMMIT_MESSAGE"
echo "✅ Changes committed!"
;;
"publish-branch")
echo "🚀 Creating new development branch for git dependency..."
# Build and sync first
./scripts/dev-workflow.sh build
./scripts/dev-workflow.sh sync
# Create new branch with timestamp
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
NEW_BRANCH="dev-$TIMESTAMP"
echo "🌿 Creating branch: $NEW_BRANCH"
git checkout -b "$NEW_BRANCH"
# Commit changes
git add .
git commit -m "Development changes - $(date)
- Updated library with latest development changes
- Synced all files to root for git dependency compatibility
- Ready for testing in consuming applications"
echo "✅ Development branch created: $NEW_BRANCH"
echo ""
echo "To push and use in consuming apps:"
echo " git push origin $NEW_BRANCH"
echo ""
echo "Then update consuming apps to use:"
echo " \"react-native-device-activity\": \"git+https://github.com/devagul93/react-native-device-activity.git#$NEW_BRANCH\""
;;
"help"|*)
echo "🛠️ React Native Device Activity Development Workflow"
echo ""
echo "Commands:"
echo " setup - Set up development environment"
echo " build - Build the library"
echo " sync - Sync library changes to root level"
echo " test-example - Test changes in the example app"
echo " commit - Build, sync, and commit changes"
echo " publish-branch - Create a new branch for git dependency testing"
echo " help - Show this help message"
echo ""
echo "Typical workflow:"
echo " 1. ./scripts/dev-workflow.sh setup"
echo " 2. Make changes in packages/react-native-device-activity/"
echo " 3. ./scripts/dev-workflow.sh build"
echo " 4. ./scripts/dev-workflow.sh test-example"
echo " 5. ./scripts/dev-workflow.sh commit"
echo " 6. ./scripts/dev-workflow.sh publish-branch"
;;
esac