Skip to content

Commit

Permalink
Merge branch 'master' of github.com:facebook/flipper
Browse files Browse the repository at this point in the history
  • Loading branch information
qichuan committed Apr 22, 2021
2 parents 2a4fb4e + 87cdd21 commit 9a138b0
Show file tree
Hide file tree
Showing 317 changed files with 5,643 additions and 3,185 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/iOS-Sample.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
name: Build iOS apps
on: [push, pull_request]
on:
push:
paths:
- "iOS/**"
- "xplat/**"
- "Flipper.podspec"
- "FlipperKit.podspec"
pull_request:
paths:
- "iOS/**"
- "xplat/**"
- "Flipper.podspec"
- "FlipperKit.podspec"

jobs:
build-sample-objc:
runs-on: macos-latest
Expand Down
24 changes: 1 addition & 23 deletions .github/workflows/iOS-dependent-pod-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ on:
- "iOS/Podspecs/**"

jobs:
lint-flipper_doubleconversion_pod:
runs-on: macos-latest
defaults:
run:
working-directory: iOS/Podspecs
steps:
- uses: actions/checkout@v2
- name: Install Dependences
run: pod repo update
- name: Lint DoubleConversion
run: pod spec lint Flipper-DoubleConversion.podspec --use-libraries --allow-warnings --verbose --skip-import-validation

lint-flipper_folly_pod:
runs-on: macos-latest
defaults:
Expand All @@ -31,17 +19,6 @@ jobs:
run: pod repo update
- name: Lint Folly
run: pod spec lint Flipper-Folly.podspec --use-libraries --allow-warnings --verbose --skip-import-validation
lint-flipper_glog_pod:
runs-on: macos-latest
defaults:
run:
working-directory: iOS/Podspecs
steps:
- uses: actions/checkout@v2
- name: Install Dependences
run: pod repo update
- name: Lint Glog
run: pod spec lint Flipper-Glog.podspec --use-libraries --allow-warnings --verbose --skip-import-validation

lint-flipper_peertalk_pod:
runs-on: macos-latest
Expand All @@ -54,6 +31,7 @@ jobs:
run: pod repo update
- name: Lint Peertalk
run: pod spec lint Flipper-PeerTalk.podspec --use-libraries --allow-warnings --verbose --skip-import-validation

lint-flipper_rsocket_pod:
runs-on: macos-latest
defaults:
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/iOS-pod-lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
name: Validate Podspecs
on: [push, pull_request]

on:
push:
paths:
- "iOS/**"
- "xplat/**"
- "Flipper.podspec"
- "FlipperKit.podspec"
pull_request:
paths:
- "iOS/**"
- "xplat/**"
- "Flipper.podspec"
- "FlipperKit.podspec"
jobs:
lint-flipperkit_pod:
runs-on: macos-latest
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
run: yarn
working-directory: ${{env.desktop-directory}}
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/publish-pods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ jobs:
- name: Update Tutorial's Podfile
run: ./scripts/update-pod-versions.sh ./ ./iOS/Tutorial/Podfile

- name: Update Sample's Podfile
run: ./scripts/update-pod-versions.sh ./ ./iOS/Sample/Podfile

- name: Update SampleSwift's Podfile
run: ./scripts/update-pod-versions.sh ./ ./iOS/SampleSwift/Podfile

- name: Update Getting Started
run: ./scripts/update-pod-versions.sh ./ ./docs/getting-started/ios-native.mdx

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bundle.map
*.bundle.js
*.bundle.map
.env
desktop-branch-*/

# conflicts with FB internal infra
.watchmanconfig
Expand Down
2 changes: 1 addition & 1 deletion Flipper.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

flipperkit_version = '0.74.0'
flipperkit_version = '0.84.0'
Pod::Spec.new do |spec|
spec.name = 'Flipper'
spec.version = flipperkit_version
Expand Down
9 changes: 8 additions & 1 deletion FlipperKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

folly_compiler_flags = '-DDEBUG=1 -DFLIPPER_OSS=1 -DFB_SONARKIT_ENABLED=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0'
yogakit_version = '~> 1.18'
flipperkit_version = '0.74.0'
flipperkit_version = '0.84.0'
Pod::Spec.new do |spec|
spec.name = 'FlipperKit'
spec.version = flipperkit_version
Expand Down Expand Up @@ -104,6 +104,9 @@ Pod::Spec.new do |spec|

spec.subspec 'FlipperKitLayoutHelpers' do |ss|
ss.header_dir = 'FlipperKitLayoutHelpers'
ss.dependency 'FlipperKit/Core'
ss.dependency 'FlipperKit/FlipperKitLayoutTextSearchable'
ss.dependency 'FlipperKit/FlipperKitHighlightOverlay'
ss.compiler_flags = folly_compiler_flags
ss.source_files = 'iOS/Plugins/FlipperKitPluginUtils/FlipperKitLayoutHelpers/**/**/*.{h,mm,m}'
ss.public_header_files = 'iOS/Plugins/FlipperKitPluginUtils/FlipperKitLayoutHelpers/FlipperKitLayoutHelpers/SKTapListener.h',
Expand All @@ -121,6 +124,10 @@ Pod::Spec.new do |spec|

spec.subspec 'FlipperKitLayoutIOSDescriptors' do |ss|
ss.header_dir = 'FlipperKitLayoutIOSDescriptors'
ss.dependency 'FlipperKit/Core'
ss.dependency 'FlipperKit/FlipperKitHighlightOverlay'
ss.dependency 'FlipperKit/FlipperKitLayoutHelpers'
ss.dependency 'YogaKit', yogakit_version
ss.compiler_flags = folly_compiler_flags
ss.source_files = 'iOS/Plugins/FlipperKitPluginUtils/FlipperKitLayoutIOSDescriptors/**/*.{h,mm,m}'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ public void onCompletion(final String json) {
job.run();
}

public void addProtobufDefinitions(
final String baseUrl, final FlipperArray callNestedMessagesPayloads) {
(new ErrorReportingRunnable(getConnection()) {
@Override
protected void runOrThrow() throws Exception {
send(
"addProtobufDefinitions",
new FlipperObject.Builder().put(baseUrl, callNestedMessagesPayloads).build());
}
})
.run();
}

private String toBase64(@Nullable byte[] bytes) {
if (bytes == null) {
return null;
Expand Down
34 changes: 34 additions & 0 deletions android/plugins/retrofit2-protobuf/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'maven'

android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
implementation project(':android')
implementation project(':network-plugin')
implementation deps.protobuf
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.github.hbmartin:protobuf_java_to_protobufjs:0.0.1"
compileOnly deps.jsr305
}
}

apply plugin: 'com.vanniktech.maven.publish'
12 changes: 12 additions & 0 deletions android/plugins/retrofit2-protobuf/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the LICENSE
# file in the root directory of this source tree.
#

POM_NAME=Retrofit2 Protobuf Adapter
POM_DESCRIPTION=Flipper plugin to automate Retrofit2 sending Protobuf definitions
POM_ARTIFACT_ID=flipper-retrofit2-protobuf-plugin
POM_PACKAGING=aar

11 changes: 11 additions & 0 deletions android/plugins/retrofit2-protobuf/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) Facebook, Inc. and its affiliates.
~
~ This source code is licensed under the MIT license found in the LICENSE
~ file in the root directory of this source tree.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.flipper.plugins.retrofit2protobuf">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.flipper.plugins.retrofit2protobuf

import com.facebook.flipper.android.AndroidFlipperClient
import com.facebook.flipper.core.FlipperArray
import com.facebook.flipper.core.FlipperObject
import com.facebook.flipper.core.FlipperValue
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin
import com.facebook.flipper.plugins.retrofit2protobuf.adapter.GenericCallDefinitionsToMessageDefinitionsIfProtobuf
import com.facebook.flipper.plugins.retrofit2protobuf.adapter.RetrofitServiceToGenericCallDefinitions
import com.facebook.flipper.plugins.retrofit2protobuf.model.CallNestedMessagesPayload
import me.haroldmartin.protobufjavatoprotobufjs.adapter.FullNamedMessagesToNestedMessages

object SendProtobufToFlipperFromRetrofit {
operator fun invoke(baseUrl: String, service: Class<*>) {
AndroidFlipperClient.getInstanceIfInitialized()?.let { client ->
(client.getPlugin(NetworkFlipperPlugin.ID) as? NetworkFlipperPlugin)
?.send(
"addProtobufDefinitions",
FlipperObject.Builder().put(
baseUrl, generateProtobufDefinitions(service).toFlipperArray()
).build()
)
}
}

private fun generateProtobufDefinitions(service: Class<*>): List<CallNestedMessagesPayload> {
return RetrofitServiceToGenericCallDefinitions(service).let { definitions ->
GenericCallDefinitionsToMessageDefinitionsIfProtobuf(definitions)
}.let { messages ->
messages.map {
CallNestedMessagesPayload(
path = it.path,
method = it.method,
requestMessageFullName = it.requestMessageFullName,
requestDefinitions = FullNamedMessagesToNestedMessages(it.requestModel),
responseMessageFullName = it.responseMessageFullName,
responseDefinitions = FullNamedMessagesToNestedMessages(it.responseModel)
)
}
}
}
}

private fun Iterable<FlipperValue>.toFlipperArray(): FlipperArray =
fold(FlipperArray.Builder()) { builder, call -> builder.put(call) }.build()
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.flipper.plugins.retrofit2protobuf.adapter

import com.facebook.flipper.plugins.retrofit2protobuf.model.FullNamedMessagesCallDefinition
import com.facebook.flipper.plugins.retrofit2protobuf.model.GenericCallDefinition
import me.haroldmartin.protobufjavatoprotobufjs.ProtobufGeneratedJavaToProtobufJs

internal object GenericCallDefinitionsToMessageDefinitionsIfProtobuf {
operator fun invoke(callDefinitions: List<GenericCallDefinition>): List<FullNamedMessagesCallDefinition> {
return callDefinitions.mapNotNull { definition ->
val responseRootAndMessages = definition.responseType?.let {
ProtobufGeneratedJavaToProtobufJs(it)
}
val requestRootAndMessages = definition.requestType?.let {
ProtobufGeneratedJavaToProtobufJs(it)
}

FullNamedMessagesCallDefinition(
path = definition.path,
method = definition.method,
responseMessageFullName = responseRootAndMessages?.rootFullName,
responseModel = responseRootAndMessages?.messages,
requestMessageFullName = requestRootAndMessages?.rootFullName,
requestModel = requestRootAndMessages?.messages
)
}
}
}
Loading

0 comments on commit 9a138b0

Please sign in to comment.