Skip to content

Commit 5cdf417

Browse files
committed
Update Example to use repo source
- Bump Version of package - Add source & react-native entries to package.json - Update example project to consume package from root of repo
1 parent fe3e987 commit 5cdf417

File tree

13 files changed

+169
-97
lines changed

13 files changed

+169
-97
lines changed

example/android/app/src/main/java/com/example/MainApplication.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.facebook.react.ReactPackage;
99
import com.facebook.soloader.SoLoader;
1010
import com.lufinkey.react.eventemitter.RNEventEmitterPackage;
11+
import com.reactlibrary.RNSpotifyRemotePackage;
1112

1213
import java.lang.reflect.InvocationTargetException;
1314
import java.util.List;
@@ -23,11 +24,15 @@ public boolean getUseDeveloperSupport() {
2324

2425
@Override
2526
protected List<ReactPackage> getPackages() {
26-
@SuppressWarnings("UnnecessaryLocalVariable")
27-
List<ReactPackage> packages = new PackageList(this).getPackages();
28-
// Packages that cannot be autolinked yet can be added manually here, for example:
29-
packages.add(new RNEventEmitterPackage());
30-
return packages;
27+
List<ReactPackage> packages = new PackageList(this).getPackages();
28+
29+
// To allow for easier development, add manually.
30+
// Not necessary in the wild as it will be autolinked
31+
packages.add(new RNSpotifyRemotePackage());
32+
33+
// Packages that cannot be autolinked yet can be added manually here:
34+
packages.add(new RNEventEmitterPackage());
35+
return packages;
3136
}
3237

3338
@Override

example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
rootProject.name = 'Spotify Remote SDK Example'
22

33
include ':react-native-spotify-remote'
4-
project(':react-native-spotify-remote').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spotify-remote/android')
4+
project(':react-native-spotify-remote').projectDir = new File(rootProject.projectDir, '../../android')
55

66
include ':react-native-events'
7-
project(':react-native-events').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-events/android')
7+
project(':react-native-events').projectDir = new File(rootProject.projectDir, '../../node_modules/react-native-events/android')
88

99
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
1010

example/babel.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1+
const path = require('path');
2+
const pak = require('../package.json');
3+
14
module.exports = {
25
presets: [
36
'module:metro-react-native-babel-preset',
47
'module:react-native-dotenv'
58
],
9+
plugins: [
10+
[
11+
'module-resolver',
12+
{
13+
alias: {
14+
[pak.name]: path.join(__dirname, '..', pak.source),
15+
},
16+
},
17+
],
18+
],
619
};

example/ios/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
platform :ios, '10.0'
22

33
node_modules_path = '../node_modules'
4+
root_node_modules_path = '../../node_modules'
45
require_relative "#{node_modules_path}/react-native/scripts/react_native_pods"
56
require_relative "#{node_modules_path}/@react-native-community/cli-platform-ios/native_modules"
67

@@ -9,8 +10,10 @@ target 'example' do
910

1011
use_react_native!(:path => config["reactNativePath"])
1112

13+
# Want to install the pod from the source directory so we can change it while developing
14+
pod 'RNSpotifyRemote', :path => "../../"
1215
# RNEventEmitter doesn't seem to support the auto detection, manually specifying instead
13-
pod 'RNEventEmitter', :path => "#{node_modules_path}/react-native-events"
16+
pod 'RNEventEmitter', :path => "#{root_node_modules_path}/react-native-events"
1417

1518
# Enables Flipper.
1619
#

example/ios/Podfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ PODS:
300300
- React-jsi (= 0.63.4)
301301
- RNEventEmitter (1.0.15):
302302
- React
303-
- RNSpotifyRemote (0.3.3):
303+
- RNSpotifyRemote (0.3.4):
304304
- React-Core
305305
- Yoga (1.14.0)
306306
- YogaKit (1.18.1):
@@ -354,8 +354,8 @@ DEPENDENCIES:
354354
- React-RCTText (from `../node_modules/react-native/Libraries/Text`)
355355
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
356356
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
357-
- RNEventEmitter (from `../node_modules/react-native-events`)
358-
- RNSpotifyRemote (from `../node_modules/react-native-spotify-remote`)
357+
- RNEventEmitter (from `../../node_modules/react-native-events`)
358+
- RNSpotifyRemote (from `../../`)
359359
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
360360

361361
SPEC REPOS:
@@ -427,9 +427,9 @@ EXTERNAL SOURCES:
427427
ReactCommon:
428428
:path: "../node_modules/react-native/ReactCommon"
429429
RNEventEmitter:
430-
:path: "../node_modules/react-native-events"
430+
:path: "../../node_modules/react-native-events"
431431
RNSpotifyRemote:
432-
:path: "../node_modules/react-native-spotify-remote"
432+
:path: "../../"
433433
Yoga:
434434
:path: "../node_modules/react-native/ReactCommon/yoga"
435435

@@ -472,10 +472,10 @@ SPEC CHECKSUMS:
472472
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
473473
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
474474
RNEventEmitter: db22b54ae7d9be0bd5725613f79a51e2bc364a93
475-
RNSpotifyRemote: f8f1251f5084d8d2ebc4d721966874a8420daa0c
475+
RNSpotifyRemote: 567768dc276b6fe386d6684f45de71dfcb437ab5
476476
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6
477477
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
478478

479-
PODFILE CHECKSUM: 0578c2c2fb41c25014dca8439d17d3ecdee64b91
479+
PODFILE CHECKSUM: 50087c231dd32c41f228e44386c2d0e1576676dc
480480

481481
COCOAPODS: 1.10.1

example/metro.config.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1-
/**
2-
* Metro configuration for React Native
3-
* https://github.com/facebook/react-native
4-
*
5-
* @format
6-
*/
1+
const path = require('path');
2+
const blacklist = require('metro-config/src/defaults/blacklist');
3+
const escape = require('escape-string-regexp');
4+
const pak = require('../package.json');
75

8-
const path = require('path')
6+
const root = path.resolve(__dirname, '..');
7+
8+
const modules = Object.keys({
9+
...pak.peerDependencies,
10+
});
911

1012
module.exports = {
13+
projectRoot: __dirname,
14+
watchFolders: [root],
15+
16+
// We need to make sure that only one version is loaded for peerDependencies
17+
// So we blacklist them at the root, and alias them to the versions in example's node_modules
18+
resolver: {
19+
blacklistRE: blacklist(
20+
modules.map(
21+
(m) =>
22+
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
23+
)
24+
),
25+
26+
extraNodeModules: modules.reduce((acc, name) => {
27+
acc[name] = path.join(__dirname, 'node_modules', name);
28+
return acc;
29+
}, {}),
30+
},
31+
1132
transformer: {
1233
getTransformOptions: async () => ({
1334
transform: {
1435
experimentalImportSupport: false,
15-
inlineRequires: false,
36+
inlineRequires: true,
1637
},
1738
}),
1839
},
19-
// workaround for an issue with symlinks encountered starting with
20-
// [email protected] / React Native 0.61
21-
// (not needed with React Native 0.60 / [email protected])
22-
resolver: {
23-
extraNodeModules: new Proxy(
24-
{},
25-
{ get: (_, name) => path.resolve('.', 'node_modules', name) }
26-
)
27-
},
28-
29-
// quick workaround for another issue with symlinks
30-
watchFolders: ['.', '..'],
3140
};
41+

example/package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
"ios": "react-native run-ios",
88
"start": "react-native start",
99
"test": "jest",
10-
"lint": "eslint .",
11-
"postinstall": "patch-package && node ./scripts/examples_postinstall.js",
12-
"update-package": "pushd ../; yarn build && popd && rimraf ./node_modules/react-native-spotify-remote && yarn add file:.."
10+
"lint": "eslint ."
1311
},
1412
"dependencies": {
1513
"@react-native-community/slider": "^2.0.8",
1614
"luxon": "^1.21.3",
1715
"native-base": "^2.13.12",
1816
"react": "16.13.1",
19-
"react-native": "0.63.4",
20-
"react-native-spotify-remote": "file:.."
17+
"react-native": "0.63.4"
2118
},
2219
"devDependencies": {
2320
"@babel/core": "^7.9.6",
@@ -29,15 +26,15 @@
2926
"@types/react-native": "^0.60.25",
3027
"@types/react-test-renderer": "^16.9.1",
3128
"babel-jest": "^25.5.1",
29+
"babel-plugin-module-resolver": "^4.1.0",
3230
"eslint": "^6.8.0",
3331
"jest": "^25.5.2",
3432
"metro-react-native-babel-preset": "^0.59.0",
3533
"patch-package": "^6.2.2",
3634
"react-native-dotenv": "^0.2.0",
37-
"react-test-renderer": "16.13.1",
38-
"typescript": "^3.7.3"
35+
"react-test-renderer": "16.13.1"
3936
},
4037
"jest": {
4138
"preset": "react-native"
4239
}
43-
}
40+
}

example/tsconfig.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,24 @@
55
"esModuleInterop": true,
66
"isolatedModules": true,
77
"jsx": "react",
8-
"lib": ["es6"],
8+
"lib": [
9+
"es6"
10+
],
911
"moduleResolution": "node",
1012
"noEmit": true,
1113
"strict": true,
12-
"target": "esnext"
14+
"target": "esnext",
15+
"baseUrl": ".",
16+
"paths": {
17+
"react-native-spotify-remote": [
18+
"../src/index"
19+
]
20+
},
1321
},
14-
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
15-
}
22+
"exclude": [
23+
"node_modules",
24+
"babel.config.js",
25+
"metro.config.js",
26+
"jest.config.js"
27+
],
28+
}

0 commit comments

Comments
 (0)