Compare commits

..
9 Commits
4 changed files with 30 additions and 12 deletions

No files matched your search

+10 -4
View File
@@ -2,6 +2,8 @@
Clean and minimalist React Native template for a quick start with TypeScript.
[![Header](https://cdn-images-1.medium.com/max/500/1*E9RnPOATuhjuNrlFkv5oSg.jpeg)](https://medium.com/@emin93/react-native-typescript-b965059109d3)
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
@@ -24,10 +26,10 @@ node setup.js
### What is included in this template?
- [TypeScript](https://github.com/Microsoft/TypeScript)
- [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)
- [TypeScript](https://github.com/Microsoft/TypeScript)
- [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)
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.
@@ -41,6 +43,10 @@ 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.
## :globe_with_meridians: Links
- ["Using React Native with TypeScript just became simple" on Medium](https://medium.com/@emin93/react-native-typescript-b965059109d3)
## :computer: Contributing
Contributions are very welcome. Please try to stay consistent with the other files I've created.
-4
View File
@@ -1,4 +0,0 @@
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('HelloWorld', () => App);
-1
View File
@@ -12,7 +12,6 @@
"keywords": [
"react-native",
"typescript",
"tslint",
"jest",
"template",
"boilerplate"
+20 -3
View File
@@ -8,14 +8,31 @@ 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 isYarnAvailable = () => {
try {
execSync('yarnpkg --version', { stdio: 'ignore' });
return true;
} catch (e) {
return false;
}
}
console.log('🔄 Please wait...');
const packager = isYarnAvailable() ? 'yarn' : 'npm';
const execOptions = { stdio: 'inherit' };
console.log('\n🔄 Please wait...\n');
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js`;
packageJson.jest = Object.assign(packageJson.jest, jestJson);
writeFile('package.json', JSON.stringify(packageJson, null, 2));
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`);
console.log(`\n📦 Installing dependencies with ${packager}...\n`);
if (packager === 'yarn') {
execSync(`yarn add ${devDependencies.join(' ')} --dev --exact`, execOptions);
} else {
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`, execOptions);
}
deleteFile('App.js');
deleteFile('__tests__/App.js');
@@ -26,4 +43,4 @@ deleteFile('README.md');
deleteFile('LICENSE');
deleteFile('setup.js');
console.log('✅ Setup completed! You can now start with: npm start');
console.log(`\n✅ Setup completed! You can now start with: ${packager} start\n`);