Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd19e744ce | ||
|
|
2452e06aea | ||
|
|
6e306bd1fd | ||
|
|
17487871d3 | ||
|
|
11abfd1c57 |
No files matched your search
@@ -1 +1,3 @@
|
||||
.travis.yml
|
||||
README.md
|
||||
LICENSE
|
||||
@@ -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.
|
||||
@@ -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
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
import { AppRegistry } from 'react-native';
|
||||
import App from './lib/App';
|
||||
|
||||
AppRegistry.registerComponent('react-native-template-typescript', () => App);
|
||||
AppRegistry.registerComponent('HelloWorld', () => App);
|
||||
@@ -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);
|
||||
})();
|
||||
@@ -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
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user