-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.js
58 lines (44 loc) · 1.95 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
52
53
54
55
56
57
// Ignite CLI plugin for Collapsible
// ----------------------------------------------------------------------------
const NPM_MODULE_NAME = 'react-native-collapsible'
const NPM_MODULE_VERSION = '0.9.0'
// const PLUGIN_PATH = __dirname
// const APP_PATH = process.cwd()
const EXAMPLE_FILE = 'CollapsibleExample.js.ejs'
const add = async function (context) {
// Learn more about context: https://infinitered.github.io/gluegun/#/context-api.md
const { ignite, filesystem } = context
// install an NPM module and link it
await ignite.addModule(NPM_MODULE_NAME, { link: true, version: NPM_MODULE_VERSION })
await ignite.addPluginComponentExample(EXAMPLE_FILE, { title: 'Collapsible Example' })
// Example of copying templates/Collapsible to App/Collapsible
// if (!filesystem.exists(`${APP_PATH}/App/Collapsible`)) {
// filesystem.copy(`${PLUGIN_PATH}/templates/Collapsible`, `${APP_PATH}/App/Collapsible`)
// }
// Example of patching a file
// ignite.patchInFile(`${APP_PATH}/App/Config/AppConfig.js`, {
// insert: `import '../Collapsible/Collapsible'\n`,
// before: `export default {`
// })
}
/**
* Remove yourself from the project.
*/
const remove = async function (context) {
// Learn more about context: https://infinitered.github.io/gluegun/#/context-api.md
const { ignite, filesystem } = context
// remove the npm module and unlink it
await ignite.removeModule(NPM_MODULE_NAME, { unlink: true })
await ignite.removePluginComponentExample(EXAMPLE_FILE)
// Example of removing App/Collapsible folder
// const removeCollapsible = await context.prompt.confirm(
// 'Do you want to remove App/Collapsible?'
// )
// if (removeCollapsible) { filesystem.remove(`${APP_PATH}/App/Collapsible`) }
// Example of unpatching a file
// ignite.patchInFile(`${APP_PATH}/App/Config/AppConfig.js`, {
// delete: `import '../Collapsible/Collapsible'\n`
// )
}
// Required in all Ignite CLI plugins
module.exports = { add, remove }