-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(framework): install-templates functionality return
* refactor(framework): install-templates functionality return Authored-By: Artur Yorsh <10753921+artyorsh@users.noreply.github.com>
- Loading branch information
Showing
17 changed files
with
314 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Add into existing project | ||
|
||
If you already have an existing code base, you're able to give UI Kitten a try as simple as `npm install`. Please refer to [Start a new App Guide](guides/start-a-new-app) if you don't have any code yet. | ||
|
||
<hr> | ||
|
||
## Install UI Kitten and Eva Design System | ||
|
||
```bash | ||
npm i react-native-ui-kitten @eva-design/eva | ||
``` | ||
|
||
<hr> | ||
|
||
## Configure Application Root | ||
|
||
At this step you have everything in place, let's configure UI Kitten to be used in your app. | ||
In your **App.js**: | ||
|
||
```js | ||
import React from 'react'; | ||
import { mapping, light as lightTheme } from '@eva-design/eva'; | ||
import { ApplicationProvider } from 'react-native-ui-kitten'; | ||
import { RootComponent } from '../path-to/root.component'; // <-- Import your application entry point | ||
|
||
const App = () => ( | ||
<ApplicationProvider | ||
mapping={mapping} | ||
theme={lightTheme}> | ||
<RootComponent /> | ||
</ApplicationProvider> | ||
); | ||
|
||
export default App; | ||
``` | ||
|
||
That's it. UI Kitten is ready now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Starting a new App | ||
|
||
If you don't have any code yet, please consider checking <a href="https://facebook.github.io/react-native/docs/getting-started" target="_blank">React Native Getting Started</a> documentation for help creating your app. | ||
|
||
<hr> | ||
|
||
## Installation | ||
|
||
First of all, you should have React Native CLI installed. | ||
|
||
```bash | ||
npm i -g react-native-cli | ||
``` | ||
|
||
<hr> | ||
|
||
## Create a New Project | ||
|
||
A new project can be created using React Native CLI tools ant UI Kitten template. | ||
|
||
```bash | ||
react-native init AwesomeApp --template ui-kitten | ||
``` | ||
|
||
Or, if you want to init with TypeScript: | ||
```bash | ||
react-native init --template ui-kitten-typescript | ||
``` | ||
|
||
That's it. UI Kitten is ready now. For the next steps, simply follow command line instructions. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
import { ApplicationProvider, Layout, Text } from 'react-native-ui-kitten'; | ||
import { mapping, light as theme } from '@eva-design/eva'; | ||
|
||
const App = () => ( | ||
<ApplicationProvider mapping={mapping} theme={theme}> | ||
<Layout style={styles.container}> | ||
<Text style={styles.text} category='h1'> | ||
Welcome to UI Kitten 😻 | ||
</Text> | ||
<Text style={styles.text} category='s1'> | ||
Start with editing App.tsx to configure your App | ||
</Text> | ||
<Text style={styles.text} appearance='hint'> | ||
For example, try changing theme to Dark by simply changing an import | ||
</Text> | ||
</Layout> | ||
</ApplicationProvider> | ||
); | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
export default App; |
15 changes: 15 additions & 0 deletions
15
src/templates/template-ui-kitten-typescript/_tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true, | ||
"isolatedModules": true, | ||
"jsx": "react", | ||
"lib": ["es6"], | ||
"moduleResolution": "node", | ||
"noEmit": true, | ||
"strict": true, | ||
"target": "esnext" | ||
}, | ||
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"] | ||
} |
4 changes: 4 additions & 0 deletions
4
src/templates/template-ui-kitten-typescript/dependencies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"@eva-design/eva": "^1.0.1", | ||
"react-native-ui-kitten": "^4.1.0" | ||
} |
7 changes: 7 additions & 0 deletions
7
src/templates/template-ui-kitten-typescript/devDependencies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"@types/jest": "latest", | ||
"@types/react-native": "latest", | ||
"@types/react-test-renderer": "latest", | ||
"@types/react": "latest", | ||
"typescript": "latest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
/** | ||
* Additional scripts needed to correctly setup a project. | ||
* Based on https://github.com/react-native-community/react-native-template-typescript. | ||
* | ||
* Runs as install script on `npm install` and replaces self after everything is done. | ||
* | ||
* - Replaces useless .js files | ||
* - Adds tsconfig.json | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
if (fs.existsSync(path.join(__dirname, '.travis.yml'))) { | ||
process.exit() | ||
} | ||
|
||
const projectFilesToDelete = [ | ||
'.flowconfig', | ||
'App.js', | ||
'__tests__/App-test.js', | ||
]; | ||
|
||
const templateFilesToAdd = [ | ||
'_tsconfig.json', | ||
]; | ||
|
||
const templateFilesToDelete = [ | ||
'install.js', | ||
'_tsconfig.json', | ||
]; | ||
|
||
const deleteFile = (filePath) => { | ||
if (!fs.existsSync(filePath)) { | ||
return | ||
} | ||
|
||
fs.unlinkSync(filePath) | ||
}; | ||
|
||
const projectPath = path.join(__dirname, '..', '..'); | ||
|
||
const projectFilePath = (fileName) => { | ||
return path.join(projectPath, fileName); | ||
}; | ||
|
||
const templateFilePath = (fileName) => { | ||
return path.join(__dirname, fileName); | ||
}; | ||
|
||
const replaceTemplateFile = (fileName) => { | ||
const newName = fileName.replace('_', ''); | ||
fs.copyFileSync(templateFilePath(fileName), templateFilePath(newName)); | ||
}; | ||
|
||
const deleteProjectFile = (fileName) => { | ||
deleteFile(projectFilePath(fileName)); | ||
}; | ||
|
||
const deleteTemplateFile = (fileName) => { | ||
deleteFile(templateFilePath(fileName)); | ||
}; | ||
|
||
templateFilesToAdd.forEach(replaceTemplateFile); | ||
projectFilesToDelete.forEach(deleteProjectFile); | ||
templateFilesToDelete.forEach(deleteTemplateFile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: 'react-native', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "react-native-template-ui-kitten-typescript", | ||
"description": "React Native template with UI Kitten and TypeScript", | ||
"version": "4.1.0", | ||
"license": "MIT", | ||
"author": "akveo <contact@akveo.com>", | ||
"homepage": "https://github.com/akveo/react-native-ui-kitten#readme", | ||
"repository": "git+https://github.com/akveo/react-native-ui-kitten.git", | ||
"bugs": { | ||
"url": "https://github.com/akveo/react-native-ui-kitten/issues" | ||
}, | ||
"keywords": [ | ||
"react-native", | ||
"ui-kitten", | ||
"typescript", | ||
"template", | ||
"boilerplate" | ||
], | ||
"scripts": { | ||
"install": "node install.js" | ||
} | ||
} |
Oops, something went wrong.