Skip to content

Commit

Permalink
Initial commit 🎉
Browse files Browse the repository at this point in the history
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2
Co-authored-by: Sebastian McKenzie <[email protected]>
Co-authored-by: John Knox <[email protected]>
Co-authored-by: Emil Sjölander <[email protected]>
Co-authored-by: Pritesh Nandgaonkar <[email protected]>
  • Loading branch information
5 people committed Jun 1, 2018
0 parents commit fbbf8cf
Show file tree
Hide file tree
Showing 659 changed files with 87,130 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
src/fb/plugins/relaydevtools/relay-devtools/*
latest
resources
templates
node_modules
flow-typed
lib
!.eslintrc.js
30 changes: 30 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/

const fbjs = require('eslint-config-fbjs');

// enforces copyright header and @format directive to be present in every file
const pattern = /^\*\n \* Copyright 2018-present Facebook\.\n \* This source code is licensed under the MIT license found in the\n \* LICENSE file in the root directory of this source tree\.\n \* @format\n./;

module.exports = {
extends: 'fbjs',
plugins: [...fbjs.plugins, 'header', 'prettier'],
rules: {
// disable rules from eslint-config-fbjs
'react/react-in-jsx-scope': 0, // not needed with our metro implementation
'no-new': 0, // new keyword needed e.g. new Notification
'no-catch-shadow': 0, // only relevant for IE8 and below
'no-bitwise': 0, // bitwise operations needed in some places
'consistent-return': 0,
'max-len': 0, // let's take prettier take care of this
indent: 0, // let's take prettier take care of this

// additional rules for this project
'header/header': [2, 'block', {pattern}],
'prettier/prettier': [2, 'fb', '@format'],
},
};
24 changes: 24 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[ignore]
.*/scripts/.*
.*/coverage/.*
.*/node_modules/.*
.*/build/.*
.*/dist/.*
.*/static/.*
<PROJECT_ROOT>/src/fb/plugins/relaydevtools/relay-devtools/DevtoolsUI.js$
.*/website/.*

[libs]
lib
flow-typed

[options]
esproposal.export_star_as=enable
module.use_strict=true
emoji=true
all=true
include_warnings=true
module.name_mapper='sonar' -> '<PROJECT_ROOT>/src/index.js'

[version]
0.69.0
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
website/build
*.xcworkspace
**/Pods/
**/xcuserdata/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libs/folly"]
path = libs/folly
url = https://github.com/facebook/folly.git
1 change: 1 addition & 0 deletions .sonarhandles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"osx": "GICWmAAS05ZnyDsCAAAAAABHIak5bnw7AAAg", "linux": "GICWmACHSiVuyDsCAAAAAABVAX1Bbnw7AAAg", "windows": "GICWmAAn5YB0yDsCAAAAAAAMdghhbnw7AAAg"}
56 changes: 56 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
os: osx
osx_image: xcode9.3

matrix:
include:
- language: node_js
node_js:
- "8"

install:
- yarn
- cd website
- yarn
- cd ..

script:
- yarn lint
- yarn build macOnly build-number=$TRAVIS_BUILD_NUMBER
- cd website
- yarn build
- cd ..

before_deploy:
- export SONAR_VERSION="v$(plutil -p $TRAVIS_BUILD_DIR/dist/mac/Sonar.app/Contents/Info.plist | awk '/CFBundleShortVersionString/ {print substr($3, 2, length($3)-2)}')"

deploy:
- provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
fqdn: fbsonar.com
local-dir: website/build/sonar
keep-history: true
on:
branch: master
- provider: releases
api_key: $GITHUB_TOKEN
file: dist/Sonar.zip
name: $SONAR_VERSION
draft: true
skip_cleanup: true
on:
branch: master

- language: objective-c

before_install:
- pod repo update

install:
- cd iOS/Sample
- pod install
- cd ../../

script:
- cd iOS/Sample
- xcodebuild clean build -workspace Sample.xcworkspace -scheme Pods-Sample
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Running Renderer",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceRoot}"
}
]
}
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--install.mutex network
3 changes: 3 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing to Sonar

We want to make contributing to this project as easy and transparent as
possible.

## Our Development Process

Changes from Facebook employees are synced to the GitHub repo automatically.
PRs from the community are imported into our internal source control and then
pushed to GitHub.

For changes affecting both, native code and JavaScript, make sure to only create
a single PR containing both parts of the code.

Although the Sonar desktop app is only released for macOS right now, it is
possible to create Windows and Linux builds of the app. Please keep this in mind
when dealing with platform-specific code.

## Pull Requests

We actively welcome your pull requests.

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. If you haven't already, complete the Contributor License Agreement ("CLA").

## Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to submit a CLA. You only need
to do this once to work on any of Facebook's open source projects.

Complete your CLA here: <https://code.facebook.com/cla>

## Issues

We use GitHub issues to track public bugs. Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue.

Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
disclosure of security bugs. In those cases, please go through the process
outlined on that page and do not file a public issue.

## Coding Style

We are using Prettier to format our source code. The styles are enforced via
eslint. Make sure everything is well formatted before creating a PR. Therefore,
run `yarn lint` and `yarn fix` to apply formatting fixes.

## License

By contributing to Sonar, you agree that your contributions will be licensed
under the LICENSE file in the root directory of this source tree.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2004-present, Facebook, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Sonar is a desktop app and client API for real time debugging of mobile apps. Sonar enables developers to quickly build plugins which expose runtime information from Android and iOS apps in a easy to use desktop interface.

# Why should I build tools on top of Sonar?

Sonar provides you with everything you need to quickly get your tools into people hands. Sonar provides a simple API for communicating with both Android and iOS devices, reconnecting if connection is lost as well as managing multiple connections. With Sonar's built in set of components it is easy to make good looking, easy to use, and powerful developer tools.

# In this repo

This repository includes all parts of Sonar. This includes:

* Sonar's desktop app built using Electron (`/src`)
* native Sonar SDKs for iOS
* native Sonar SDKs for Android
* Plugins:
* Logs (`/src/device-plugins/logs`)
* Layout inspector (`/src/plugins/layout`)
* Network inspector (`/src/plugins/network`)
* website and documentation (`/website` / `/docs`)

# Getting started

## Requirements

* macOS (while Sonar is buildable using other systems as well, only macOS is officially supported)
* node >= 8
* yarn >= 1.5
* iOS developer tools (for developing iOS plugins)
* Android SDK and adb

## Starting the desktop app

```
git clone https://github.com/facebook/Sonar.git
cd Sonar
yarn
yarn start
```

## Building the desktop app

```
yarn build [macOnly] [build-number=$buildNumber]
```

A binary for macOS is created in `dist/mac`. `macOnly` and `build-number` are optional params.

## Documentation

Find the full documentation for this project at [fbsonar.com](https://fbsonar.com/).

## Contributing and license

See the CONTRIBUTING file for how to help out.
Sonar is MIT licensed, as found in the LICENSE file.
4 changes: 4 additions & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.sonar">
</manifest>
63 changes: 63 additions & 0 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required (VERSION 3.6.0)
project(sonar CXX C)
set(CMAKE_VERBOSE_MAKEFILE on)

set(PACKAGE_NAME "sonar")

add_compile_options(-DFOLLY_NO_CONFIG
-DSONAR_JNI_EXTERNAL=1
-DFB_SONARKIT_ENABLED=1
-DFOLLY_HAVE_MEMRCHR
-DFOLLY_MOBILE=1
-DFOLLY_USE_LIBCPP=1
-DFOLLY_HAVE_LIBJEMALLOC=0
-DFOLLY_HAVE_PREADV=0
-frtti
-fexceptions
-std=c++14
-Wno-error
-Wno-unused-local-typedefs
-Wno-unused-variable
-Wno-sign-compare
-Wno-comment
-Wno-return-type
-Wno-tautological-constant-compare
)

file(GLOB SOURCES android/sonar.cpp)
add_library(${PACKAGE_NAME} SHARED ${SOURCES})
target_include_directories(${PACKAGE_NAME} PUBLIC "./")

set(libjnihack_DIR ${CMAKE_SOURCE_DIR}/../libs/jni-hack/)
set(libfbjni_DIR ${CMAKE_SOURCE_DIR}/../libs/fbjni/src/main/cpp/include/)
set(libsonar_DIR ${CMAKE_SOURCE_DIR}/../xplat/)
set(third_party_ndk build/third-party-ndk)
set(libfolly_DIR ${third_party_ndk}/folly/)
set(glog_DIR ${third_party_ndk}/glog)
set(BOOST_DIR ${third_party_ndk}/boost/boost_1_63_0/)


set(build_DIR ${CMAKE_SOURCE_DIR}/build)

set(fbjni_build_DIR ${build_DIR}/fbjni/${ANDROID_ABI})
set(libsonar_build_DIR ${build_DIR}/libsonar/${ANDROID_ABI})
set(libfolly_build_DIR ${build_DIR}/libfolly/${ANDROID_ABI})

file(MAKE_DIRECTORY ${build_DIR})

add_subdirectory(${libsonar_DIR} ${libsonar_build_DIR})
add_subdirectory(${libfbjni_DIR}/../ ${fbjni_build_DIR})

target_include_directories(${PACKAGE_NAME} PRIVATE
${libjnihack_DIR}
${libfbjni_DIR}
${libsonar_DIR}
${libfolly_DIR}
${glog_DIR}
${glog_DIR}/../
${glog_DIR}/glog-0.3.5/src/
${BOOST_DIR}
${BOOST_DIR}/../
)

target_link_libraries(${PACKAGE_NAME} fb sonarcpp)
Loading

0 comments on commit fbbf8cf

Please sign in to comment.