Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.

Commit 7d3c672

Browse files
committed
Updates the module to install react-native-maps 0.26.1
1 parent 9009b57 commit 7d3c672

File tree

3 files changed

+7
-42
lines changed

3 files changed

+7
-42
lines changed

plugin.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,17 @@
22
// ----------------------------------------------------------------------------
33

44
const NPM_MODULE_NAME = 'react-native-maps'
5-
const NPM_MODULE_VERSION = '0.16.4'
6-
const PLAY_SERVICES_VERSION = '16.1.0'
7-
// const PLUGIN_PATH = __dirname
8-
const APP_PATH = process.cwd()
5+
const NPM_MODULE_VERSION = '0.26.1'
96
const EXAMPLE_FILE = 'MapsExample.js.ejs'
107

11-
const GRADLE_CONFIG = `
12-
compile(project(':react-native-maps')) {
13-
exclude group: 'com.google.android.gms', module: 'play-services-base'
14-
exclude group: 'com.google.android.gms', module: 'play-services-maps'
15-
}
16-
compile 'com.google.android.gms:play-services-base:${PLAY_SERVICES_VERSION}'
17-
compile 'com.google.android.gms:play-services-maps:${PLAY_SERVICES_VERSION}'
18-
`
19-
208
const add = async function (context) {
219
const { ignite, print } = context
2210

2311
// install a npm module and link it
24-
await ignite.addModule(NPM_MODULE_NAME, { version: NPM_MODULE_VERSION, link: true })
12+
await ignite.addModule(NPM_MODULE_NAME, { version: NPM_MODULE_VERSION, link: false })
2513
// add our component example to the plugin component examples screen
2614
await ignite.addPluginComponentExample(EXAMPLE_FILE, { title: 'Maps Example' })
2715

28-
// add the app build gradle config
29-
ignite.patchInFile(`${APP_PATH}/android/app/build.gradle`, {
30-
insert: GRADLE_CONFIG,
31-
replace: `\n compile project(':react-native-maps')`
32-
})
33-
3416
print.warning(`⚠️ Using Google Maps on Android? ⚠️`)
3517
print.info('')
3618
print.info(` If you're using Google Maps on Android (this is the default), there's still another step.`)
@@ -56,15 +38,10 @@ const remove = async function (context) {
5638
const { ignite } = context
5739

5840
// remove the npm module and unlink it
59-
await ignite.removeModule(NPM_MODULE_NAME, { unlink: true })
41+
await ignite.removeModule(NPM_MODULE_NAME, { unlink: false })
6042
// remove our component example from the plugin component examples screen
6143
await ignite.removePluginComponentExample(EXAMPLE_FILE)
6244

63-
// Remove the app build gradle config we added
64-
ignite.patchInFile(`${APP_PATH}/android/app/build.gradle`, {
65-
delete: GRADLE_CONFIG
66-
})
67-
6845
// TODO: Remove API key
6946
// android/app/src/main/AndroidManifest.xml
7047
}

test/add.test.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ test('adds the proper npm module, component example, patches a file', async t =>
77
// spy on few things so we know they're called
88
const addModule = sinon.spy()
99
const addPluginComponentExample = sinon.spy()
10-
const patchInFile = sinon.spy()
1110

1211
// mock a context
1312
const context = {
14-
ignite: { addModule, addPluginComponentExample, patchInFile },
13+
ignite: { addModule, addPluginComponentExample },
1514
print: {
1615
warning: T,
1716
info: T,
@@ -21,16 +20,11 @@ test('adds the proper npm module, component example, patches a file', async t =>
2120

2221
await plugin.add(context)
2322
t.true(
24-
addModule.calledWith('react-native-maps', { version: '0.16.4', link: true })
23+
addModule.calledWith('react-native-maps', { version: '0.26.1', link: false })
2524
)
2625
t.true(
2726
addPluginComponentExample.calledWith('MapsExample.js.ejs', {
2827
title: 'Maps Example'
2928
})
3029
)
31-
// Gradle patching
32-
t.true(patchInFile.called)
33-
t.is(patchInFile.args[0][0], `${process.cwd()}/android/app/build.gradle`)
34-
t.true(patchInFile.args[0][1].insert.length > 0)
35-
t.true(patchInFile.args[0][1].replace.length > 0)
3630
})

test/remove.test.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,13 @@ const plugin = require('../plugin')
55
test('removes maps', async t => {
66
const removeModule = sinon.spy()
77
const removePluginComponentExample = sinon.spy()
8-
const patchInFile = sinon.spy()
98

109
const context = {
11-
ignite: { removeModule, removePluginComponentExample, patchInFile }
10+
ignite: { removeModule, removePluginComponentExample }
1211
}
1312

1413
await plugin.remove(context)
1514

16-
t.true(removeModule.calledWith('react-native-maps', { unlink: true }))
15+
t.true(removeModule.calledWith('react-native-maps', { unlink: false }))
1716
t.true(removePluginComponentExample.calledWith('MapsExample.js.ejs'))
18-
19-
// Gradle unpatching
20-
t.true(patchInFile.called)
21-
t.is(patchInFile.args[0][0], `${process.cwd()}/android/app/build.gradle`)
22-
t.true(patchInFile.args[0][1].delete.length > 0)
2317
})

0 commit comments

Comments
 (0)