Skip to content

Commit

Permalink
feat(module): Setup CircleCI, semantic-release, and rename to @react-…
Browse files Browse the repository at this point in the history
…native-community/voice (#226)

BREAKING CHANGE: Module renamed to @react-native-community/voice
  • Loading branch information
safaiyeh committed Feb 19, 2020
1 parent d16815b commit 2bf77e0
Show file tree
Hide file tree
Showing 10 changed files with 4,414 additions and 637 deletions.
46 changes: 46 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 2.1
orbs:
rn: react-native-community/[email protected]

jobs:
checkout_code:
executor: rn/linux_js
steps:
- checkout
- persist_to_workspace:
root: .
paths: .

analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Run ESLint
command: yarn lint

release:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Publish to NPM
command: yarn semantic-release || true

workflows:
ci:
jobs:
- checkout_code
- analyse_js:
requires:
- checkout_code
- release:
requires:
- analyse_js
filters:
branches:
only: master
13 changes: 0 additions & 13 deletions .editorconfig

This file was deleted.

70 changes: 2 additions & 68 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,69 +1,3 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"jest": true,
"es6": true,
},
"plugins": [
"react",
"react-native",
"flowtype",
"import"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:import/errors"
],
"rules": {
"comma-dangle": [2, "always-multiline"],
"quotes": [2, "single", { "allowTemplateLiterals": true }],
"react/prop-types": 0,
"no-case-declarations": 0,
"react/jsx-no-bind": 0,
"react/display-name": 0,
"new-cap": 0,
"react-native/no-unused-styles": 2,
"react-native/split-platform-components": 0,
"react-native/no-inline-styles": 0,
"react-native/no-color-literals": 0,
"no-unexpected-multiline": 0,
"no-class-assign": 1,
"no-console": 2,
"object-curly-spacing": [1, "always"],
"flowtype/define-flow-type": 1,
"flowtype/use-flow-type": 1,
"import/first": 2,
"import/default": 0,
"no-unused-vars": ["error", { "ignoreRestSiblings": true }],
"import/named": 0,
"import/namespace": [2, { "allowComputed": true }],
"no-extra-boolean-cast": 0,
"import/no-duplicates": 2,
"react/no-deprecated": 0
},
"settings": {
"import/resolver": {
"node": {
"extensions":[
".js",
".android.js",
".ios.js",
".json"
]
}
}
},
"globals": {
"__DEV__": true
}
}
"extends": "@react-native-community"
}
45 changes: 0 additions & 45 deletions .jshintrc

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<p align="center">A speech-to-text library for <a href="https://facebook.github.io/react-native/">React Native.</a></p>

```sh
npm i react-native-voice --save
npm i @react-native-community/voice --save
```

## Table of contents
Expand All @@ -27,16 +27,16 @@ npm i react-native-voice --save
<p align="center">Manually or automatically link the NativeModule</p>

```sh
react-native link react-native-voice
react-native link @react-native-community/voice
```

### Manually Link Android
- In `android/setting.gradle`

```gradle
...
include ':react-native-voice', ':app'
project(':react-native-voice').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voice/android')
include ':@react-native-community_voice', ':app'
project(':@react-native-community_voice').projectDir = new File(rootProject.projectDir, '../node_modules/voice/android')
```

- In `android/app/build.gradle`
Expand All @@ -45,7 +45,7 @@ project(':react-native-voice').projectDir = new File(rootProject.projectDir, '..
...
dependencies {
...
compile project(':react-native-voice')
compile project(':@react-native-community_voice')
}
```

Expand Down Expand Up @@ -74,19 +74,19 @@ public class MainActivity extends Activity implements ReactApplication {

### Manually Link iOS

- Drag the Voice.xcodeproj from the react-native-voice/ios folder to the Libraries group on Xcode in your poject. [Manual linking](https://facebook.github.io/react-native/docs/linking-libraries-ios.html)
- Drag the Voice.xcodeproj from the @react-native-community/voice/ios folder to the Libraries group on Xcode in your poject. [Manual linking](https://facebook.github.io/react-native/docs/linking-libraries-ios.html)

- Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag the static library, lib.Voice.a, from the Libraries/Voice.xcodeproj/Products folder to Link Binary With Libraries


<h2 align="center">Usage</h2>

<p align="center"><a href="https://github.com/wenkesj/react-native-voice/tree/master/VoiceTest">Full example for Android and iOS.</a></p>
<p align="center"><a href="https://github.com/react-native-community/voice/tree/master/VoiceTest">Full example for Android and iOS.</a></p>

### Example

```javascript
import Voice from 'react-native-voice';
import Voice from '@react-native-community/voice';
import React, {Component} from 'react';

class VoiceTest extends Component {
Expand Down
36 changes: 13 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
"name": "react-native-voice",
"name": "@react-native-community/voice",
"description": "React Native Native Voice library for iOS and Android",
"version": "0.3.0",
"author": "Sam Wenke <[email protected]>",
"homepage": "https://github.com/react-native-community/react-native-voice",
"homepage": "https://github.com/react-native-community/voice",
"devDependencies": {
"eslint": "^5.3.0",
"eslint-plugin-flowtype": "^2.50.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-react": "^7.10.0",
"eslint-plugin-react-native": "^3.2.1",
"pre-commit": "^1.2.2",
"prettier": "^1.12.0",
"@react-native-community/eslint-config": "^0.0.7",
"@semantic-release/git": "^9.0.0",
"eslint": "^6.8.0",
"lint-staged": "^7.2.0",
"babel-eslint": "^8.2.6",
"react": "16.4.2",
"react-native": "^0.56.0"
"react-native": "^0.56.0",
"semantic-release": "^17.0.4"
},
"keywords": [
"android",
Expand All @@ -25,25 +21,19 @@
"voice"
],
"license": "MIT",
"lint-staged": {
"*.js": [
"yarn prettier",
"eslint --fix",
"git add"
]
},
"main": "src/index.js",
"peerDependencies": {
"react-native": ">=0.40.0"
},
"pre-commit": "lint:staged",
"repository": {
"type": "git",
"url": "git://github.com/react-native-community/react-native-voice.git"
"url": "git://github.com/react-native-community/voice.git"
},
"scripts": {
"lint": "eslint src --max-warnings=0",
"lint:staged": "lint-staged",
"prettier": "prettier --write --single-quote true --trailing-comma all --print-width 100"
"lint": "eslint src/*",
"semantic-release": "semantic-release"
},
"dependencies": {
"invariant": "^2.2.4"
}
}
4 changes: 2 additions & 2 deletions react-native-voice.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = package['name']
s.name = "react-native-voice"
s.version = package['version']
s.summary = package['description']
s.license = package['license']
Expand All @@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.homepage = package['homepage']
s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/react-native-community/react-native-voice.git" }
s.source = { :git => "https://github.com/react-native-community/voice.git" }
s.source_files = "ios/**/*.{h,m}"

s.dependency 'React'
Expand Down
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
import invariant from 'invariant';

const { Voice } = NativeModules;

// NativeEventEmitter is only availabe on React Native platforms, so this conditional is used to avoid import conflicts in the browser/server
const voiceEmitter = Platform.OS !== 'web' ? new NativeEventEmitter(Voice) : null;
const voiceEmitter =
Platform.OS !== 'web' ? new NativeEventEmitter(Voice) : null;

class RCTVoice {
constructor() {
Expand Down Expand Up @@ -125,7 +127,10 @@ class RCTVoice {
* */
getSpeechRecognitionServices() {
if (Platform.OS !== 'android') {
throw new Exception('Speech recognition services can be queried for only on Android');
invariant(
Voice,
'Speech recognition services can be queried for only on Android',
);
}

return Voice.getSpeechRecognitionServices();
Expand Down
Loading

0 comments on commit 2bf77e0

Please sign in to comment.