Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
302409b2aa | ||
|
|
81d1c898df | ||
|
|
ecd2665a7c | ||
|
|
ea53a939b8 | ||
|
|
ef94173200 | ||
|
|
fe8abb8848 | ||
|
|
8e8013e835 | ||
|
|
b80fb5d42b | ||
|
|
59bf3c6fc3 | ||
|
|
3f295f24b9 | ||
|
|
166dd361d2 | ||
|
|
2139753b44 |
No files matched your search
@@ -2,14 +2,17 @@
|
||||
|
||||
Clean and minimalist React Native template for a quick start with TypeScript.
|
||||
|
||||
[](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
|
||||
|
||||
- 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
|
||||
- Seamless integration with the React Native CLI! :sparkles:
|
||||
- Consistent with the default React Native template (no additional stuff)
|
||||
- React Native TypeScript transformer directly integrated into the packager (no separate process for `tsc`)
|
||||
- Unit testing in TypeScript with TS Jest
|
||||
- Always latest dependencies :raised_hands:
|
||||
|
||||
## :arrow_forward: Quick Start
|
||||
|
||||
@@ -23,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.
|
||||
|
||||
@@ -40,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.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import { AppRegistry } from 'react-native';
|
||||
import App from './App';
|
||||
|
||||
AppRegistry.registerComponent('HelloWorld', () => App);
|
||||
@@ -12,7 +12,6 @@
|
||||
"keywords": [
|
||||
"react-native",
|
||||
"typescript",
|
||||
"tslint",
|
||||
"jest",
|
||||
"template",
|
||||
"boilerplate"
|
||||
|
||||
@@ -8,16 +8,32 @@ 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('index.js');
|
||||
deleteFile('App.js');
|
||||
deleteFile('__tests__/App.js');
|
||||
deleteFile('.flowconfig');
|
||||
@@ -27,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`);
|
||||
Reference in new issue
Block a user