react_native_util 0.3.2 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +47 -30
- data/lib/assets/patches/version.yml +3 -0
- data/lib/assets/templates/Podfile.erb +2 -2
- data/lib/react_native_util/converter.rb +14 -34
- data/lib/react_native_util/core_ext/xcodeproj.rb +32 -0
- data/lib/react_native_util/metadata.rb +1 -1
- data/lib/react_native_util/project.rb +1 -1
- data/lib/react_native_util/rake/react_pod_task.rb +7 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db3f0bd398429fdfe2b21315c6fbf4c0e269d1c2194d3b4c0db07339ae03921
|
4
|
+
data.tar.gz: '08a734aa93a6bb080eb7fd63f932165a5fd3a4652f847cf2b5d74c03ee557df5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c20af6ddf47bf1f33d6a2239b1495744aa51b494b7c0e17ac0d02f0bf5972a45f527f81d20e230b539206cb4e1cf913fcd66f4eecdc3d3271eabc0f21ec3a2b2
|
7
|
+
data.tar.gz: 8052d6b6998484502602087f15dc62d1b8eda7ad6f74e6f8868ea7490be2cd4e4dcfa6e793bc81be62d47fd3784a9e06c472096337652f5330b102ccc81959e6
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ alternative to performing manual surgery on a project in Xcode.
|
|
17
17
|
|
18
18
|
## Prerequisites
|
19
19
|
|
20
|
-
_macOS required_
|
20
|
+
_macOS & Xcode required_
|
21
21
|
|
22
22
|
The react_pod command requires `yarn` from Homebrew and the `react-native-cli`.
|
23
23
|
If installing react_native_util from the Homebrew tap, `yarn` will be
|
@@ -53,6 +53,11 @@ brew install react-native-cli
|
|
53
53
|
brew install jdee/tap/react_native_util
|
54
54
|
```
|
55
55
|
|
56
|
+
Include react-native-cli from Homebrew:
|
57
|
+
```bash
|
58
|
+
brew install jdee/tap/react_native_util --with-react-native-cli
|
59
|
+
```
|
60
|
+
|
56
61
|
## Gemfile
|
57
62
|
|
58
63
|
```Ruby
|
@@ -94,35 +99,42 @@ git status
|
|
94
99
|
|
95
100
|
_Typical command output:_
|
96
101
|
```
|
97
|
-
2019-05-
|
98
|
-
|
99
|
-
2019-05-
|
100
|
-
2019-05-
|
101
|
-
2019-05-
|
102
|
-
2019-05-
|
103
|
-
2019-05-
|
104
|
-
2019-05-
|
105
|
-
2019-05-
|
106
|
-
2019-05-
|
107
|
-
2019-05-
|
108
|
-
2019-05-
|
109
|
-
2019-05-
|
110
|
-
2019-05-
|
111
|
-
2019-05-
|
112
|
-
2019-05-
|
113
|
-
2019-05-
|
114
|
-
|
115
|
-
|
116
|
-
2019-05-
|
117
|
-
2019-05-
|
118
|
-
2019-05-
|
119
|
-
2019-05-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
2019-05-
|
125
|
-
|
102
|
+
2019-05-14T12:30:50-07:00 react_native_util react_pod v0.4.0
|
103
|
+
2019-05-14T12:30:52-07:00 Darwin 18.5.0 x86_64
|
104
|
+
2019-05-14T12:30:52-07:00 Ruby 2.3.7: ~/.rvm/rubies/ruby-2.3.7/bin/ruby
|
105
|
+
2019-05-14T12:30:52-07:00 RubyGems 3.0.3: ~/.rvm/rubies/ruby-2.3.7/bin/gem
|
106
|
+
2019-05-14T12:30:52-07:00 Bundler 1.17.3: ~/.rvm/gems/ruby-2.3.7/bin/bundle
|
107
|
+
2019-05-14T12:30:52-07:00 react-native-cli: ~/.nvm/versions/node/v10.15.0/bin/react-native
|
108
|
+
2019-05-14T12:30:52-07:00 react-native-cli: 2.0.1
|
109
|
+
2019-05-14T12:30:52-07:00 react-native: 0.59.8
|
110
|
+
2019-05-14T12:30:52-07:00 yarn 1.16.0: /usr/local/bin/yarn
|
111
|
+
2019-05-14T12:30:53-07:00 cocoapods 1.6.1: ~/.rvm/gems/ruby-2.3.7/bin/pod
|
112
|
+
2019-05-14T12:30:53-07:00 cocoapods-core: 1.6.1
|
113
|
+
2019-05-14T12:30:53-07:00 package.json:
|
114
|
+
2019-05-14T12:30:53-07:00 app name: "TestApp"
|
115
|
+
2019-05-14T12:30:53-07:00 Found Xcode project at ~/github/jdee/react_native_util/examples/TestApp/ios/TestApp.xcodeproj
|
116
|
+
2019-05-14T12:30:53-07:00 Dependencies:
|
117
|
+
2019-05-14T12:30:53-07:00 react-native-webview
|
118
|
+
2019-05-14T12:30:53-07:00 Unlinking dependencies
|
119
|
+
[✔] react-native unlink react-native-webview success in 0.5 s
|
120
|
+
2019-05-14T12:30:53-07:00 Generating ios/Podfile
|
121
|
+
2019-05-14T12:30:53-07:00 Removing Libraries from TestApp
|
122
|
+
2019-05-14T12:30:53-07:00 Removing Libraries from TestAppTests
|
123
|
+
2019-05-14T12:30:53-07:00 Removing Libraries group
|
124
|
+
2019-05-14T12:30:53-07:00 Linking dependencies
|
125
|
+
[✔] react-native link react-native-webview success in 0.6 s
|
126
|
+
2019-05-14T12:30:54-07:00 Generating Pods project and ios/TestApp.xcworkspace
|
127
|
+
[✔] pod install success in 10.2 s
|
128
|
+
2019-05-14T12:31:04-07:00 Conversion complete ✅
|
129
|
+
2019-05-14T12:31:04-07:00 $ open ios/TestApp.xcworkspace
|
130
|
+
```
|
131
|
+
|
132
|
+
## Convert your own app with Rake
|
133
|
+
|
134
|
+
From this repo:
|
135
|
+
|
136
|
+
```bash
|
137
|
+
bundle exec rake react_pod[/path/to/your/app]
|
126
138
|
```
|
127
139
|
|
128
140
|
## Rake task
|
@@ -144,6 +156,11 @@ ReactNativeUtil::Rake::ReactPodTask.new(
|
|
144
156
|
)
|
145
157
|
```
|
146
158
|
|
159
|
+
Override `chdir` at the command line:
|
160
|
+
```bash
|
161
|
+
rake react_pod[/path/to/another/rn/project]
|
162
|
+
```
|
163
|
+
|
147
164
|
## Ruby script
|
148
165
|
|
149
166
|
```Ruby
|
@@ -7,7 +7,7 @@ target '<%= app_name %>' do
|
|
7
7
|
Core
|
8
8
|
CxxBridge
|
9
9
|
DevSupport
|
10
|
-
<%=
|
10
|
+
<%= app_target.subspecs_from_libraries.join("\n ") %>
|
11
11
|
]
|
12
12
|
pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
|
13
13
|
pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
<% if test_target %>
|
20
20
|
target '<%= test_target.name %>' do
|
21
|
-
pod 'React', path: '../node_modules/react-native', subspecs: %w[Core CxxBridge]
|
21
|
+
pod 'React', path: '../node_modules/react-native', subspecs: <%= (%w[Core CxxBridge] + test_target.subspecs_from_libraries).inspect %>
|
22
22
|
pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
|
23
23
|
pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
|
24
24
|
end
|
@@ -87,7 +87,8 @@ module ReactNativeUtil
|
|
87
87
|
|
88
88
|
project.validate_app_target!
|
89
89
|
|
90
|
-
|
90
|
+
# Not used at the moment
|
91
|
+
# load_react_podspec!
|
91
92
|
|
92
93
|
# 2. Detect native dependencies in Libraries group.
|
93
94
|
log 'Dependencies:'
|
@@ -106,27 +107,23 @@ module ReactNativeUtil
|
|
106
107
|
load_xcodeproj!
|
107
108
|
load_react_project!
|
108
109
|
|
109
|
-
#
|
110
|
+
# 4. Add Start Packager script
|
110
111
|
project.add_packager_script_from react_project
|
111
112
|
|
112
|
-
#
|
113
|
-
|
113
|
+
# 5. Generate boilerplate Podfile.
|
114
|
+
generate_podfile!
|
114
115
|
|
115
|
-
#
|
116
|
+
# 6. Remove Libraries group from Xcode project.
|
116
117
|
project.remove_libraries_group
|
117
|
-
|
118
118
|
project.save
|
119
119
|
|
120
|
-
#
|
121
|
-
generate_podfile!
|
122
|
-
|
123
|
-
# 6. Run react-native link for each dependency.
|
120
|
+
# 7. Run react-native link for each dependency (adds to Podfile).
|
124
121
|
log 'Linking dependencies'
|
125
122
|
deps_to_add.each do |dep|
|
126
123
|
run_command_with_spinner! 'react-native', 'link', dep, log: File.join(Dir.tmpdir, "react-native-link-#{dep}.log")
|
127
124
|
end
|
128
125
|
|
129
|
-
#
|
126
|
+
# 8. pod install
|
130
127
|
log "Generating Pods project and ios/#{app_name}.xcworkspace"
|
131
128
|
command = %w[pod install]
|
132
129
|
command << '--repo-update' if options[:repo_update]
|
@@ -134,10 +131,10 @@ module ReactNativeUtil
|
|
134
131
|
|
135
132
|
log 'Conversion complete ✅'
|
136
133
|
|
137
|
-
# 8. SCM/git (add, commit - optional)
|
138
|
-
|
139
134
|
# 9. Open workspace/build
|
140
135
|
execute 'open', File.join('ios', "#{app_name}.xcworkspace")
|
136
|
+
|
137
|
+
# 10. TODO: SCM/git (add, commit - optional)
|
141
138
|
end
|
142
139
|
|
143
140
|
# Read the contents of ./package.json into @package_json
|
@@ -227,18 +224,6 @@ module ReactNativeUtil
|
|
227
224
|
# rubocop: enable Security/Eval
|
228
225
|
end
|
229
226
|
|
230
|
-
def load_subspecs_from_libraries
|
231
|
-
roots = project.library_roots - %w[React]
|
232
|
-
@subspecs_from_libraries = roots.select { |r| Project::DEFAULT_DEPENDENCIES.include?(r) }.map do |root|
|
233
|
-
case root
|
234
|
-
when 'RCTLinking'
|
235
|
-
'RCTLinkingIOS'
|
236
|
-
else
|
237
|
-
root
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
227
|
# The name of the app as specified in package.json
|
243
228
|
# @return [String] the app name
|
244
229
|
def app_name
|
@@ -268,15 +253,11 @@ module ReactNativeUtil
|
|
268
253
|
|
269
254
|
def check_repo_status!
|
270
255
|
# If the git command is not installed, there's not much we can do.
|
271
|
-
# Don't want to use verify_git here, which will insist on installing
|
272
|
-
# the command. The logic of that method could change.
|
273
256
|
return if `which git`.empty?
|
274
257
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
return unless $?.success?
|
279
|
-
end
|
258
|
+
`git rev-parse --git-dir > /dev/null 2>&1`
|
259
|
+
# Not a git repo
|
260
|
+
return unless $?.success?
|
280
261
|
|
281
262
|
`git diff-index --quiet HEAD --`
|
282
263
|
return if $?.success?
|
@@ -287,8 +268,7 @@ module ReactNativeUtil
|
|
287
268
|
# Load the contents of the React.xcodeproj project from node_modules.
|
288
269
|
# @raise Xcodeproj::PlainInformative in case of most failures
|
289
270
|
def load_react_project!
|
290
|
-
|
291
|
-
@react_project = Project.open path
|
271
|
+
@react_project = Project.open 'node_modules/react-native/React/React.xcodeproj'
|
292
272
|
end
|
293
273
|
end
|
294
274
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
|
3
|
+
module Xcodeproj
|
4
|
+
class Project
|
5
|
+
module Object
|
6
|
+
class AbstractTarget
|
7
|
+
def subspecs_from_libraries
|
8
|
+
libs = frameworks_build_phase.files.select do |file|
|
9
|
+
path = file.file_ref.pretty_print
|
10
|
+
next false unless /^lib(.+)\.a$/.match?(path)
|
11
|
+
next false if path == 'libReact.a'
|
12
|
+
|
13
|
+
# project is a ReactNativeUtil::Project
|
14
|
+
# #static_libs is from the Libraries group
|
15
|
+
project.static_libs.include?(path)
|
16
|
+
end
|
17
|
+
|
18
|
+
libs.map do |lib|
|
19
|
+
root = lib.file_ref.pretty_print.sub(/^lib(.*)\.a$/, '\1')
|
20
|
+
|
21
|
+
case root
|
22
|
+
when 'RCTLinking'
|
23
|
+
'RCTLinkingIOS'
|
24
|
+
else
|
25
|
+
root
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Conversion tools for React Native projects
|
2
2
|
module ReactNativeUtil
|
3
3
|
NAME = 'react_native_util'
|
4
|
-
VERSION = '0.
|
4
|
+
VERSION = '0.4.0'
|
5
5
|
SUMMARY = 'Community utility CLI for React Native projects'
|
6
6
|
DESCRIPTION = 'Converts a project created with react-native init to use CocoaPods with the ' \
|
7
7
|
'React pod from node_modules. This preserves compatibility with ' \
|
@@ -7,6 +7,10 @@ module ReactNativeUtil
|
|
7
7
|
# Rakefile:
|
8
8
|
# require 'react_native_util/rake'
|
9
9
|
# ReactNativeUtil::Rake::ReactPodTask.new chdir: '/path/to/rn/app'
|
10
|
+
#
|
11
|
+
# The task accepts a path argument that overrides chdir. If neither
|
12
|
+
# chdir or a path argument is provided, the command executes in the
|
13
|
+
# current directory.
|
10
14
|
class ReactPodTask < ::Rake::TaskLib
|
11
15
|
include Util
|
12
16
|
def initialize(
|
@@ -16,8 +20,9 @@ module ReactNativeUtil
|
|
16
20
|
repo_update: boolean_env_var?(:REACT_NATIVE_UTIL_REPO_UPDATE)
|
17
21
|
)
|
18
22
|
desc description
|
19
|
-
task name do
|
20
|
-
|
23
|
+
task name, %i[path] do |_task, opts|
|
24
|
+
project_dir = opts[:path] || chdir
|
25
|
+
Dir.chdir project_dir do
|
21
26
|
Converter.new(repo_update: repo_update).convert_to_react_pod!
|
22
27
|
end
|
23
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_native_util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Dee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '1.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- README.md
|
238
238
|
- bin/react_native_util
|
239
239
|
- bin/rn
|
240
|
+
- lib/assets/patches/version.yml
|
240
241
|
- lib/assets/templates/Podfile.erb
|
241
242
|
- lib/react_native_util.rb
|
242
243
|
- lib/react_native_util/cli.rb
|
@@ -244,6 +245,7 @@ files:
|
|
244
245
|
- lib/react_native_util/core_ext/io.rb
|
245
246
|
- lib/react_native_util/core_ext/regexp.rb
|
246
247
|
- lib/react_native_util/core_ext/string.rb
|
248
|
+
- lib/react_native_util/core_ext/xcodeproj.rb
|
247
249
|
- lib/react_native_util/exceptions.rb
|
248
250
|
- lib/react_native_util/metadata.rb
|
249
251
|
- lib/react_native_util/project.rb
|