-
Notifications
You must be signed in to change notification settings - Fork 4
/
plugin.js
52 lines (39 loc) · 1.6 KB
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Ignite plugin for Elements
// ----------------------------------------------------------------------------
const RNElements = 'react-native-elements'
const EXAMPLE_FILE = 'ElementsExample.js'
const add = async function (context) {
const { ignite } = context
// install a npm module and link it
await ignite.addModule(RNElements)
// copy the component example file (if examples are turned on)
await ignite.addPluginComponentExample(EXAMPLE_FILE, { title: 'Elements Example' })
// Example of copying templates/Elements to App/Elements
// if (!filesystem.exists(`${APP_PATH}/App/Elements`)) {
// filesystem.copy(`${PLUGIN_PATH}/templates/Elements`, `${APP_PATH}/App/Elements`)
// }
// Example of patching a file
// ignite.patchInFile(`${APP_PATH}/App/Config/AppConfig.js`, {
// insert: `import '../Elements/Elements'\n`,
// before: `export default {`
// })
}
/**
* Remove yourself from the project.
*/
const remove = async function (context) {
const { ignite } = context
// remove the npm module and unlink it
await ignite.removeModule(RNElements)
// remove the component example
await ignite.removePluginComponentExample(EXAMPLE_FILE)
// Example of removing App/Elements folder
// const removeElements = await context.prompt.confirm(
// 'Do you want to remove App/Elements?'
// )
// if (removeElements) { filesystem.remove(`${APP_PATH}/App/Elements`) }
// Example of unpatching a file
// patching.replaceInFile(`${APP_PATH}/App/Config/AppConfig.js`, `import '../Elements/Elements'\n`, '')
}
// Required in all Ignite plugins
module.exports = { add, remove }