Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea1c65e260 | ||
|
|
e4eca8679a | ||
|
|
79b0923763 |
No files matched your search
@@ -1,2 +1 @@
|
||||
.travis.yml
|
||||
setup/
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
*
|
||||
* Generated with the TypeScript template
|
||||
* https://github.com/emin93/react-native-template-typescript
|
||||
*/
|
||||
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
|
||||
const instructions = Platform.select({
|
||||
ios: 'Press Cmd+R to reload,\n' +
|
||||
'Cmd+D or shake for dev menu',
|
||||
android: 'Double tap R on your keyboard to reload,\n' +
|
||||
'Shake or press menu button for dev menu',
|
||||
});
|
||||
|
||||
interface Props {};
|
||||
export default class App extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit App.tsx
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
{instructions}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
},
|
||||
});
|
||||
@@ -4,6 +4,13 @@ Clean and minimalist React Native template for a quick start with TypeScript.
|
||||
|
||||
This template can be used with the React Native CLI, which means it doesn't mess with the platform specific files. Instead of including a lot of dependencies, my aim when creating this template was to provide a very easy and minimalist way to start your React Native project with TypeScript. Of course you can always include other dependencies as you need them.
|
||||
|
||||
## :star: Features
|
||||
|
||||
- Seamless integration with the React Native CLI
|
||||
- Always latest dependencies
|
||||
- React Native TypeScript transformer directly integrated into the packager! (No separate process for TSC)
|
||||
- Unit testing in TypeScript with Jest
|
||||
|
||||
## :arrow_forward: Quick Start
|
||||
|
||||
```
|
||||
@@ -20,8 +27,6 @@ node setup.js
|
||||
- [React Native TypeScript transformer](https://github.com/ds300/react-native-typescript-transformer)
|
||||
- [Type definitions for React & React Native](https://github.com/DefinitelyTyped/DefinitelyTyped)
|
||||
- [TS Jest](https://github.com/kulshekhar/ts-jest)
|
||||
- [TSLint](https://github.com/palantir/tslint)
|
||||
- [TSLint React](https://github.com/palantir/tslint-react)
|
||||
|
||||
This template always uses the latest versions of the dependencies at the time when the setup script (`node setup.js`) is being executed. This means you don't have to worry about old versions.
|
||||
|
||||
@@ -35,7 +40,7 @@ The React Native CLI supports automatic installation of production dependencies
|
||||
|
||||
The React Native CLI will do everything just as without a template and afterwards overwrite the files with the ones from this template. This means you don't have to worry about incompatibility issues with later React Native upgrades.
|
||||
|
||||
## :hearts: Contributing
|
||||
## :computer: Contributing
|
||||
|
||||
Contributions are very welcome. Please try to stay consistent with the other files I've created.
|
||||
|
||||
|
||||
+9
-6
@@ -1,9 +1,12 @@
|
||||
import * as React from "react";
|
||||
import "react-native";
|
||||
import { create } from "react-test-renderer";
|
||||
import 'react-native';
|
||||
import * as React from 'react';
|
||||
import App from '../App';
|
||||
|
||||
import App from "../src/App";
|
||||
// Note: test renderer must be required after react-native.
|
||||
import * as renderer from 'react-test-renderer';
|
||||
|
||||
it("renders correctly", () => {
|
||||
const tree = create(<App exampleProp="helloWorld" />);
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer.create(
|
||||
<App />
|
||||
);
|
||||
});
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"react-native-setup-typescript": "*"
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
[
|
||||
"typescript",
|
||||
"tslint",
|
||||
"tslint-react",
|
||||
"react-native-typescript-transformer",
|
||||
"ts-jest",
|
||||
"@types/react",
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { AppRegistry } from 'react-native';
|
||||
import App from './src/App';
|
||||
import App from './App';
|
||||
|
||||
AppRegistry.registerComponent('HelloWorld', () => App);
|
||||
+12
-10
@@ -2,18 +2,22 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const packageJson = require('../../package.json');
|
||||
const jestJson = require('../../jest.json');
|
||||
const devDependencies = require('../../devDependencies.json');
|
||||
const packageJson = require('./package.json');
|
||||
const jestJson = require('./jest.json');
|
||||
const devDependencies = require('./devDependencies.json');
|
||||
|
||||
const deleteFile = (fileName) => fs.unlinkSync(path.join(process.cwd(), '../../', fileName));
|
||||
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), '../../' fileName), data);
|
||||
const deleteFile = (fileName) => fs.unlinkSync(path.join(process.cwd(), fileName));
|
||||
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), fileName), data);
|
||||
|
||||
console.log('🔄 Please wait...');
|
||||
|
||||
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js`;
|
||||
packageJson.scripts.lint = 'tslint -c tslint.json "src/**/*.{ts,tsx}"';
|
||||
packageJson.jest = Object.assign(packageJson.jest, jestJson);
|
||||
writeFile('package.json', JSON.stringify(packageJson, null, 2));
|
||||
|
||||
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`);
|
||||
|
||||
deleteFile('index.js');
|
||||
deleteFile('App.js');
|
||||
deleteFile('__tests__/App.js');
|
||||
deleteFile('.flowconfig');
|
||||
@@ -21,8 +25,6 @@ deleteFile('devDependencies.json');
|
||||
deleteFile('jest.json');
|
||||
deleteFile('README.md');
|
||||
deleteFile('LICENSE');
|
||||
deleteFile('setup.js');
|
||||
|
||||
let commandsToExecute = `cd ../../ && npm i ${devDependencies.join(' ')} --save-dev --save-exact`;
|
||||
commandsToExecute += '&& npm uninstall react-native-setup-typescript --save'
|
||||
|
||||
execSync(commandsToExecute);
|
||||
console.log('✅ Setup completed! You can now start with: npm start');
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "react-native-setup-typescript",
|
||||
"version": "1.0.1",
|
||||
"description": "Do NOT use this as a standalone package. See: https://www.npmjs.com/package/react-native-template-typescript",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"install": "node index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/emin93/react-native-template-typescript.git"
|
||||
},
|
||||
"author": "Emin Khateeb <emin@emin.ch>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/emin93/react-native-template-typescript/issues"
|
||||
},
|
||||
"homepage": "https://github.com/emin93/react-native-template-typescript#readme"
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
import * as React from "react";
|
||||
import { Platform, StyleSheet, Text, View } from "react-native";
|
||||
|
||||
const instructions = Platform.select({
|
||||
android: "Double tap R on your keyboard to reload,\n" +
|
||||
"Shake or press menu button for dev menu",
|
||||
ios: "Press Cmd+R to reload,\n" +
|
||||
"Cmd+D or shake for dev menu",
|
||||
});
|
||||
|
||||
interface IProps {
|
||||
exampleProp: string;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
exampleState: string;
|
||||
}
|
||||
|
||||
export default class App extends React.Component<IProps, IState> {
|
||||
public render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit src/App.tsx
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
{instructions}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
alignItems: "center",
|
||||
backgroundColor: "#F5FCFF",
|
||||
flex: 1,
|
||||
justifyContent: "center",
|
||||
},
|
||||
instructions: {
|
||||
color: "#333333",
|
||||
marginBottom: 5,
|
||||
textAlign: "center",
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
margin: 10,
|
||||
textAlign: "center",
|
||||
},
|
||||
});
|
||||
@@ -4,6 +4,7 @@
|
||||
"jsx": "react",
|
||||
"noEmit": true,
|
||||
"moduleResolution": "node",
|
||||
"noImplicitAny": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": [
|
||||
"tslint:recommended",
|
||||
"tslint-react"
|
||||
],
|
||||
"jsRules": {},
|
||||
"rules": {},
|
||||
"rulesDirectory": []
|
||||
}
|
||||
Reference in new issue
Block a user