ignite-dev-screens
Advanced tools
Comparing version
67
index.js
@@ -1,7 +0,41 @@ | ||
const Shell = require('shelljs') | ||
const copyDevScreens = async function (context) { | ||
// grab some features | ||
const { parameters, print, strings, ignite } = context | ||
const { isBlank } = strings | ||
const screens = ["AllComponentsScreen", "APITestingScreen", "DeviceInfoScreen", "PresentationScreen", "ThemeScreen", "PluginExamplesScreen", "LaunchScreen"] | ||
const jobs = [] | ||
screens.map((screen) => { | ||
jobs.push( | ||
{ | ||
template: `${screen}.ejs`, | ||
target: `ignite/DevScreens/${screen}.js` | ||
}, | ||
{ | ||
template: `${screen}Style.ejs`, | ||
target: `ignite/DevScreens/Styles/${screen}Style.js` | ||
} | ||
) | ||
}) | ||
jobs.push( | ||
{ | ||
template: 'DevscreensButton.ejs', | ||
target: 'ignite/DevScreens/DevscreensButton.js' | ||
}, | ||
{ | ||
template: 'DevscreensButtonStyle.ejs', | ||
target: 'ignite/DevScreens/Styles/DevscreensButtonStyle.js' | ||
} | ||
) | ||
// make the templates | ||
await ignite.copyBatch(context, jobs, {}) | ||
} | ||
const add = async function (context) { | ||
console.log('Adding Ignite Dev Screens') | ||
const { patching, filesystem, print } = context | ||
const { patching, filesystem, print, system } = context | ||
const { warning } = print | ||
@@ -12,19 +46,19 @@ | ||
// Copy the the screens to containers folder | ||
Shell.exec('ignite generate dev-screens') | ||
// // Copy the the screens to containers folder | ||
await copyDevScreens(context) | ||
// Set App/Config/DebugSettings.js showDevScreens to __DEV__ | ||
// Set App/Config/DebugConfig.js showDevScreens to __DEV__ | ||
context.ignite.setDebugConfig('showDevScreens', '__DEV__', true) | ||
// Insert a function that renders the dev screens as part of the JSX in the navigation | ||
const launchScreen = `${process.cwd}/App/Containers/LaunchScreen.js` | ||
const launchScreen = `${process.cwd()}/App/Containers/LaunchScreen.js` | ||
if (filesystem.exists(launchScreen)) { | ||
if (!patching.existsInFile(launchScreen, 'import DevscreensButton')) { | ||
patching.insertInFile(launchScreen, 'export Default class', 'import DevscreensButton from \'./Components/DevscreensButton.js\'\n', false) | ||
if (!patching.isInFile(launchScreen, 'import DevscreensButton')) { | ||
patching.insertInFile(launchScreen, 'import styles', 'import DevscreensButton from \'./Components/DevscreensButton.js\'\n', false) | ||
} | ||
if (!patching.existsInFile(launchScreen, '<DevscreensButton />')) { | ||
if (!patching.isInFile(launchScreen, '<DevscreensButton />')) { | ||
patching.insertInFile(launchScreen, '</ScrollView>', '<DevscreensButton />', false) | ||
} | ||
} else { | ||
warning('LaunchScreen.js not found. Please manually link the PresentationScreen from your primary screen/navigation or open it manually via Reactotron.') | ||
warning('LaunchScreen.js not found. Please manually link the PresentationScreen from your primary screen/navigation.') | ||
} | ||
@@ -38,3 +72,3 @@ | ||
const remove = async function (context) { | ||
{ filesystem } = context | ||
const { filesystem } = context | ||
@@ -47,6 +81,3 @@ console.log('Removing Ignite Dev Screens') | ||
// Delete screens from containers folder | ||
// TODO: Use un-generate once #564 is resolved | ||
filesystem.remove('App/Containers/DevScreens') | ||
filesystem.remove('App/Components/DevscreensButton.js') | ||
filesystem.remove('App/Components/Styles/DevscreensButtonStyles.js') | ||
filesystem.remove('ignite/DevScreens') | ||
@@ -60,3 +91,3 @@ // Remove App/Config/DebugSettings.js showDevScreens value | ||
// Remove dev screens button from launch page, if launch page is found | ||
const launchScreen = `${process.cwd}/App/Containers/LaunchScreen.js` | ||
const launchScreen = `${process.cwd()}/App/Containers/LaunchScreen.js` | ||
if (filesystem.exists(launchScreen)) { | ||
@@ -63,0 +94,0 @@ patching.replaceInFile(launchScreen, 'import DevscreensButton', '') |
{ | ||
"name": "ignite-dev-screens", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"devEngines": { | ||
"node": ">=7.x", | ||
"npm": ">=4.x" | ||
}, | ||
"dependencies": { | ||
"ignite": "2.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
30589
2.6%0
-100%20
5.26%74
-11.9%- Removed