Compare commits

...
5 Commits
8 changed files with 58 additions and 34 deletions

No files matched your search

+2
View File
@@ -1 +1,3 @@
.travis.yml
README.md
LICENSE
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Emin Khateeb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+1 -1
View File
@@ -11,7 +11,7 @@ way to start your React Native project with TypeScript. Of course you can always
```
react-native init MyApp --template typescript
cd MyApp
node scripts/install.sh
node setup.js
```
## :question: FAQ
+6 -4
View File
@@ -1,4 +1,6 @@
{
"@types/react": "16.0.40",
"@types/react-native": "0.52.16"
}
[
"@types/react",
"@types/react-native",
"typescript",
"npm-run-all"
]
+1 -1
View File
@@ -1,4 +1,4 @@
import { AppRegistry } from 'react-native';
import App from './lib/App';
AppRegistry.registerComponent('react-native-template-typescript', () => App);
AppRegistry.registerComponent('HelloWorld', () => App);
-25
View File
@@ -1,25 +0,0 @@
const fs = require('fs');
const path = require('path');
const packageJson = require('../package.json');
const devDependencies = require('../devDependencies.json');
const isInScriptsDirectory = fs.existsSync(path.join(process.cwd(), 'install.js'));
const pathPrefix = isInScriptsDirectory ? '../' : '';
const deleteFile = (fileName) => fs.unlinkSync(path.join(process.cwd(), `${pathPrefix}${fileName}`));
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), `${pathPrefix}${fileName}`), data);
(() => {
deleteFile('App.js');
})();
(() => {
if (!packageJson.devDependencies) {
packageJson.devDependencies = {};
}
packageJson.devDependencies = Object.assign(packageJson.devDependencies, devDependencies);
const data = JSON.stringify(packageJson, null, 2);
writeFile('package.json', data);
})();
+23
View File
@@ -0,0 +1,23 @@
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const packageJson = require('./package.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);
packageJson.scripts.rn = packageJson.scripts.start;
packageJson.scripts.ts = 'node_modules/.bin/tsc -w';
packageJson.scripts.start = 'npm-run-all -p -r rn ts';
writeFile('package.json', JSON.stringify(packageJson, null, 2));
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`);
deleteFile('App.js');
deleteFile('.flowconfig');
deleteFile('devDependencies.json');
deleteFile('setup.js');
console.log('✅ Setup completed! You can now start with: npm start');
+4 -3
View File
@@ -8,9 +8,10 @@ const instructions = Platform.select({
'Shake or press menu button for dev menu',
});
export interface Props { }
interface Props { }
interface State { }
export default class App extends React.Component<Props> {
export default class App extends React.Component<Props, State> {
render() {
return (
<View style={styles.container}>
@@ -18,7 +19,7 @@ export default class App extends React.Component<Props> {
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit App.js
To get started, edit src/App.tsx
</Text>
<Text style={styles.instructions}>
{instructions}