Skip to content

Commit 2bf77e0

Browse files
committed
feat(module): Setup CircleCI, semantic-release, and rename to @react-native-community/voice (#226)
BREAKING CHANGE: Module renamed to @react-native-community/voice
1 parent d16815b commit 2bf77e0

10 files changed

+4414
-637
lines changed

.circleci/config.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: 2.1
2+
orbs:
3+
rn: react-native-community/[email protected]
4+
5+
jobs:
6+
checkout_code:
7+
executor: rn/linux_js
8+
steps:
9+
- checkout
10+
- persist_to_workspace:
11+
root: .
12+
paths: .
13+
14+
analyse_js:
15+
executor: rn/linux_js
16+
steps:
17+
- attach_workspace:
18+
at: .
19+
- rn/yarn_install
20+
- run:
21+
name: Run ESLint
22+
command: yarn lint
23+
24+
release:
25+
executor: rn/linux_js
26+
steps:
27+
- attach_workspace:
28+
at: .
29+
- rn/yarn_install
30+
- run:
31+
name: Publish to NPM
32+
command: yarn semantic-release || true
33+
34+
workflows:
35+
ci:
36+
jobs:
37+
- checkout_code
38+
- analyse_js:
39+
requires:
40+
- checkout_code
41+
- release:
42+
requires:
43+
- analyse_js
44+
filters:
45+
branches:
46+
only: master

.editorconfig

-13
This file was deleted.

.eslintrc

+2-68
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,3 @@
11
{
2-
"parser": "babel-eslint",
3-
"env": {
4-
"browser": true,
5-
"node": true,
6-
"jest": true,
7-
"es6": true,
8-
},
9-
"plugins": [
10-
"react",
11-
"react-native",
12-
"flowtype",
13-
"import"
14-
],
15-
"parserOptions": {
16-
"ecmaVersion": 6,
17-
"sourceType": "module",
18-
"ecmaFeatures": {
19-
"modules": true
20-
}
21-
},
22-
"extends": [
23-
"eslint:recommended",
24-
"plugin:react/recommended",
25-
"plugin:import/errors"
26-
],
27-
"rules": {
28-
"comma-dangle": [2, "always-multiline"],
29-
"quotes": [2, "single", { "allowTemplateLiterals": true }],
30-
"react/prop-types": 0,
31-
"no-case-declarations": 0,
32-
"react/jsx-no-bind": 0,
33-
"react/display-name": 0,
34-
"new-cap": 0,
35-
"react-native/no-unused-styles": 2,
36-
"react-native/split-platform-components": 0,
37-
"react-native/no-inline-styles": 0,
38-
"react-native/no-color-literals": 0,
39-
"no-unexpected-multiline": 0,
40-
"no-class-assign": 1,
41-
"no-console": 2,
42-
"object-curly-spacing": [1, "always"],
43-
"flowtype/define-flow-type": 1,
44-
"flowtype/use-flow-type": 1,
45-
"import/first": 2,
46-
"import/default": 0,
47-
"no-unused-vars": ["error", { "ignoreRestSiblings": true }],
48-
"import/named": 0,
49-
"import/namespace": [2, { "allowComputed": true }],
50-
"no-extra-boolean-cast": 0,
51-
"import/no-duplicates": 2,
52-
"react/no-deprecated": 0
53-
},
54-
"settings": {
55-
"import/resolver": {
56-
"node": {
57-
"extensions":[
58-
".js",
59-
".android.js",
60-
".ios.js",
61-
".json"
62-
]
63-
}
64-
}
65-
},
66-
"globals": {
67-
"__DEV__": true
68-
}
69-
}
2+
"extends": "@react-native-community"
3+
}

.jshintrc

-45
This file was deleted.

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<p align="center">A speech-to-text library for <a href="https://facebook.github.io/react-native/">React Native.</a></p>
77

88
```sh
9-
npm i react-native-voice --save
9+
npm i @react-native-community/voice --save
1010
```
1111

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

2929
```sh
30-
react-native link react-native-voice
30+
react-native link @react-native-community/voice
3131
```
3232

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

3636
```gradle
3737
...
38-
include ':react-native-voice', ':app'
39-
project(':react-native-voice').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-voice/android')
38+
include ':@react-native-community_voice', ':app'
39+
project(':@react-native-community_voice').projectDir = new File(rootProject.projectDir, '../node_modules/voice/android')
4040
```
4141

4242
- In `android/app/build.gradle`
@@ -45,7 +45,7 @@ project(':react-native-voice').projectDir = new File(rootProject.projectDir, '..
4545
...
4646
dependencies {
4747
...
48-
compile project(':react-native-voice')
48+
compile project(':@react-native-community_voice')
4949
}
5050
```
5151

@@ -74,19 +74,19 @@ public class MainActivity extends Activity implements ReactApplication {
7474

7575
### Manually Link iOS
7676

77-
- 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)
77+
- 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)
7878

7979
- 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
8080

8181

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

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

8686
### Example
8787

8888
```javascript
89-
import Voice from 'react-native-voice';
89+
import Voice from '@react-native-community/voice';
9090
import React, {Component} from 'react';
9191

9292
class VoiceTest extends Component {

package.json

+13-23
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
{
2-
"name": "react-native-voice",
2+
"name": "@react-native-community/voice",
33
"description": "React Native Native Voice library for iOS and Android",
44
"version": "0.3.0",
55
"author": "Sam Wenke <[email protected]>",
6-
"homepage": "https://github.com/react-native-community/react-native-voice",
6+
"homepage": "https://github.com/react-native-community/voice",
77
"devDependencies": {
8-
"eslint": "^5.3.0",
9-
"eslint-plugin-flowtype": "^2.50.0",
10-
"eslint-plugin-import": "^2.13.0",
11-
"eslint-plugin-react": "^7.10.0",
12-
"eslint-plugin-react-native": "^3.2.1",
13-
"pre-commit": "^1.2.2",
14-
"prettier": "^1.12.0",
8+
"@react-native-community/eslint-config": "^0.0.7",
9+
"@semantic-release/git": "^9.0.0",
10+
"eslint": "^6.8.0",
1511
"lint-staged": "^7.2.0",
16-
"babel-eslint": "^8.2.6",
1712
"react": "16.4.2",
18-
"react-native": "^0.56.0"
13+
"react-native": "^0.56.0",
14+
"semantic-release": "^17.0.4"
1915
},
2016
"keywords": [
2117
"android",
@@ -25,25 +21,19 @@
2521
"voice"
2622
],
2723
"license": "MIT",
28-
"lint-staged": {
29-
"*.js": [
30-
"yarn prettier",
31-
"eslint --fix",
32-
"git add"
33-
]
34-
},
3524
"main": "src/index.js",
3625
"peerDependencies": {
3726
"react-native": ">=0.40.0"
3827
},
39-
"pre-commit": "lint:staged",
4028
"repository": {
4129
"type": "git",
42-
"url": "git://github.com/react-native-community/react-native-voice.git"
30+
"url": "git://github.com/react-native-community/voice.git"
4331
},
4432
"scripts": {
45-
"lint": "eslint src --max-warnings=0",
46-
"lint:staged": "lint-staged",
47-
"prettier": "prettier --write --single-quote true --trailing-comma all --print-width 100"
33+
"lint": "eslint src/*",
34+
"semantic-release": "semantic-release"
35+
},
36+
"dependencies": {
37+
"invariant": "^2.2.4"
4838
}
4939
}

react-native-voice.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require 'json'
33
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
44

55
Pod::Spec.new do |s|
6-
s.name = package['name']
6+
s.name = "react-native-voice"
77
s.version = package['version']
88
s.summary = package['description']
99
s.license = package['license']
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
1212
s.homepage = package['homepage']
1313
s.platform = :ios, "9.0"
1414

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

1818
s.dependency 'React'

src/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
2+
import invariant from 'invariant';
23

34
const { Voice } = NativeModules;
45

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

810
class RCTVoice {
911
constructor() {
@@ -125,7 +127,10 @@ class RCTVoice {
125127
* */
126128
getSpeechRecognitionServices() {
127129
if (Platform.OS !== 'android') {
128-
throw new Exception('Speech recognition services can be queried for only on Android');
130+
invariant(
131+
Voice,
132+
'Speech recognition services can be queried for only on Android',
133+
);
129134
}
130135

131136
return Voice.getSpeechRecognitionServices();

0 commit comments

Comments
 (0)