Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
100447b7d5 | ||
|
|
4fc8174c3f | ||
|
|
ffcf32376d | ||
|
|
9e7a6483bb | ||
|
|
44e7ad381c | ||
|
|
9da8429132 | ||
|
|
371438e4e2 | ||
|
|
3c0fb203c8 | ||
|
|
be099fa8ce | ||
|
|
ad5174f050 | ||
|
|
e55051bb09 | ||
|
|
da099611c2 | ||
|
|
6052e12972 | ||
|
|
5c7ed69e2b | ||
|
|
afb35e18bc | ||
|
|
0cb1761f5b | ||
|
|
e48a1e4354 | ||
|
|
d1cc0b9707 | ||
|
|
df0149ac5f | ||
|
|
10fac6c22f | ||
|
|
172b32155d | ||
|
|
2d7334d61e | ||
|
|
caae886d8f | ||
|
|
270f516448 | ||
|
|
8ed8b19828 | ||
|
|
c66f735c19 | ||
|
|
b2f6208cb4 | ||
|
|
3b10c51f74 | ||
|
|
8d885ab3f5 | ||
|
|
b937346ac2 | ||
|
|
cd047d58f0 | ||
|
|
6a8da82688 | ||
|
|
ac23b8ac83 | ||
|
|
987fe89238 | ||
|
|
5361316879 | ||
|
|
c11df248ab | ||
|
|
ec3a826edc | ||
|
|
a585faa237 | ||
|
|
919ebb922e | ||
|
|
57233a492b | ||
|
|
b8f4b89aca | ||
|
|
80e970bda8 | ||
|
|
dc432eea2d | ||
|
|
8c5248b2b3 | ||
|
|
11fa0420ed |
No files matched your search
+1
-56
@@ -1,57 +1,2 @@
|
|||||||
# OSX
|
|
||||||
#
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# Xcode
|
|
||||||
#
|
|
||||||
build/
|
|
||||||
*.pbxuser
|
|
||||||
!default.pbxuser
|
|
||||||
*.mode1v3
|
|
||||||
!default.mode1v3
|
|
||||||
*.mode2v3
|
|
||||||
!default.mode2v3
|
|
||||||
*.perspectivev3
|
|
||||||
!default.perspectivev3
|
|
||||||
xcuserdata
|
|
||||||
*.xccheckout
|
|
||||||
*.moved-aside
|
|
||||||
DerivedData
|
|
||||||
*.hmap
|
|
||||||
*.ipa
|
|
||||||
*.xcuserstate
|
|
||||||
project.xcworkspace
|
|
||||||
|
|
||||||
# Android/IntelliJ
|
|
||||||
#
|
|
||||||
build/
|
|
||||||
.idea
|
|
||||||
.gradle
|
|
||||||
local.properties
|
|
||||||
*.iml
|
|
||||||
|
|
||||||
# Visual Studio Code
|
|
||||||
#
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
# node.js
|
|
||||||
#
|
|
||||||
node_modules/
|
node_modules/
|
||||||
npm-debug.log
|
.vscode/
|
||||||
yarn-error.log
|
|
||||||
|
|
||||||
# BUCK
|
|
||||||
buck-out/
|
|
||||||
\.buckd/
|
|
||||||
*.keystore
|
|
||||||
|
|
||||||
# fastlane
|
|
||||||
#
|
|
||||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
|
||||||
# screenshots whenever they are needed.
|
|
||||||
# For more information about the recommended setup visit:
|
|
||||||
# https://docs.fastlane.tools/best-practices/source-control/
|
|
||||||
|
|
||||||
*/fastlane/report.xml
|
|
||||||
*/fastlane/Preview.html
|
|
||||||
*/fastlane/screenshots
|
|
||||||
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "node"
|
- "node"
|
||||||
install: true
|
cache:
|
||||||
|
directories:
|
||||||
|
- "node_modules"
|
||||||
deploy:
|
deploy:
|
||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
|
|||||||
@@ -4,37 +4,28 @@
|
|||||||
*
|
*
|
||||||
* Generated with the TypeScript template
|
* Generated with the TypeScript template
|
||||||
* https://github.com/emin93/react-native-template-typescript
|
* https://github.com/emin93/react-native-template-typescript
|
||||||
|
*
|
||||||
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
import React, {Component} from 'react';
|
||||||
import {
|
import {Platform, StyleSheet, Text, View} from 'react-native';
|
||||||
Platform,
|
|
||||||
StyleSheet,
|
|
||||||
Text,
|
|
||||||
View
|
|
||||||
} from 'react-native';
|
|
||||||
|
|
||||||
const instructions = Platform.select({
|
const instructions = Platform.select({
|
||||||
ios: 'Press Cmd+R to reload,\n' +
|
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
|
||||||
'Cmd+D or shake for dev menu',
|
android:
|
||||||
android: 'Double tap R on your keyboard to reload,\n' +
|
'Double tap R on your keyboard to reload,\n' +
|
||||||
'Shake or press menu button for dev menu',
|
'Shake or press menu button for dev menu',
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {};
|
interface Props {}
|
||||||
export default class App extends Component<Props> {
|
export default class App extends Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.welcome}>
|
<Text style={styles.welcome}>Welcome to React Native!</Text>
|
||||||
Welcome to React Native!
|
<Text style={styles.instructions}>To get started, edit App.tsx</Text>
|
||||||
</Text>
|
<Text style={styles.instructions}>{instructions}</Text>
|
||||||
<Text style={styles.instructions}>
|
|
||||||
To get started, edit App.tsx
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.instructions}>
|
|
||||||
{instructions}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,56 @@
|
|||||||
# :space_invader: React Native Template TypeScript · [](https://www.npmjs.com/package/react-native-template-typescript) [](https://travis-ci.org/emin93/react-native-template-typescript)
|
# :space_invader: React Native Template TypeScript · [](https://travis-ci.org/emin93/react-native-template-typescript)
|
||||||
|
|
||||||
Clean and minimalist React Native template for a quick start with TypeScript.
|
Clean and minimalist React Native template for a quick start with TypeScript.
|
||||||
|
|
||||||
[](https://medium.com/@emin93/react-native-typescript-b965059109d3)
|
[](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
|
## :star: Features
|
||||||
|
|
||||||
- Seamless integration with the React Native CLI! :sparkles:
|
- Seamlessly integrated into the React Native CLI! :sparkles:
|
||||||
- Consistent with the default React Native template (no additional stuff)
|
- Consistent with the default React Native template
|
||||||
- React Native TypeScript transformer directly integrated into the packager (no separate process for `tsc`)
|
- Always latest dependencies :raised_hands:
|
||||||
- Unit testing in TypeScript with TS Jest
|
|
||||||
- Always latest dependencies :raised_hands:
|
|
||||||
|
|
||||||
## :arrow_forward: Quick Start
|
## :arrow_forward: Quick Start
|
||||||
|
|
||||||
```
|
```bash
|
||||||
react-native init MyApp --template typescript
|
react-native init MyApp --template typescript && node MyApp/setup.js
|
||||||
cd MyApp
|
|
||||||
node setup.js
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## :question: FAQ
|
## :question: FAQ
|
||||||
|
|
||||||
### What is included in this template?
|
### Why this template when React Native 0.57+ supports TypeScript out of the box?
|
||||||
|
|
||||||
- [TypeScript](https://github.com/Microsoft/TypeScript)
|
Actually, when React Native 0.57 was announced, I planned to stop maintenance on this template. But after further evaluation, there's still quite a lot of manual work to do (add type definitions for React & React Native, create a `.tsconfig` for type checking, etc.) to properly set up a React Native 0.57+ TypeScript project. And that's where this template comes in and does that work for you. :raised_hands:
|
||||||
- [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.
|
### What additional dependencies are included in this template?
|
||||||
|
|
||||||
|
- [TypeScript](https://github.com/Microsoft/TypeScript)
|
||||||
|
- [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 `react-native init` command is being executed. This means you don't have to worry about old versions.
|
||||||
|
|
||||||
Lots of :heart: and credits to the owners and maintainers of those packages.
|
Lots of :heart: and credits to the owners and maintainers of those packages.
|
||||||
|
|
||||||
### Why the setup script?
|
### Why the setup script?
|
||||||
|
|
||||||
The React Native CLI supports automatic installation of production dependencies only. Since TypeScript and the other dependencies are dev dependencies, the setup script is being used to install those. It also takes care of obsolete files like the `.flowconfig` and the `setup.js` itself after the setup.
|
It deletes obsolete files like the `.flowconfig` and the `setup.js` itself after the setup.
|
||||||
|
|
||||||
### How will this template affect the React Native CLI workflow?
|
### How to do type checking?
|
||||||
|
|
||||||
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.
|
`npm run tsc`
|
||||||
|
|
||||||
|
### Does debugging work?
|
||||||
|
|
||||||
|
Yes it does.
|
||||||
|
|
||||||
|
[](https://medium.com/@emin93/react-native-typescript-b965059109d3)
|
||||||
|
|
||||||
## :globe_with_meridians: Links
|
## :globe_with_meridians: Links
|
||||||
|
|
||||||
- ["Using React Native with TypeScript just became simple" on Medium](https://medium.com/@emin93/react-native-typescript-b965059109d3)
|
- ["Using React Native with TypeScript just became simple" on Medium](https://medium.com/@emin93/react-native-typescript-b965059109d3)
|
||||||
|
- ["24 tips for React Native you probably want to know" on Albert Gao's blog](http://albertgao.xyz/2018/05/30/24-tips-for-react-native-you-probably-want-to-know/#9-For-Typescript)
|
||||||
|
- ["3 Easy Steps to Set Up React Native with TypeScript, Jest and Enzyme" on Medium by Jan Hesters](https://medium.com/@jan.hesters/3-easy-steps-to-set-up-react-native-with-typescript-jest-and-enzyme-592ca042262f)
|
||||||
|
|
||||||
## :computer: Contributing
|
## :computer: Contributing
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
import 'react-native';
|
import 'react-native';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import App from '../App';
|
import App from '../App';
|
||||||
@@ -6,7 +10,5 @@ import App from '../App';
|
|||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
|
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
const tree = renderer.create(
|
renderer.create(<App />);
|
||||||
<App />
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
# OSX
|
||||||
|
#
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Xcode
|
||||||
|
#
|
||||||
|
build/
|
||||||
|
*.pbxuser
|
||||||
|
!default.pbxuser
|
||||||
|
*.mode1v3
|
||||||
|
!default.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
!default.mode2v3
|
||||||
|
*.perspectivev3
|
||||||
|
!default.perspectivev3
|
||||||
|
xcuserdata
|
||||||
|
*.xccheckout
|
||||||
|
*.moved-aside
|
||||||
|
DerivedData
|
||||||
|
*.hmap
|
||||||
|
*.ipa
|
||||||
|
*.xcuserstate
|
||||||
|
project.xcworkspace
|
||||||
|
|
||||||
|
# Android/IntelliJ
|
||||||
|
#
|
||||||
|
build/
|
||||||
|
.idea
|
||||||
|
.gradle
|
||||||
|
local.properties
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
#
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# node.js
|
||||||
|
#
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
|
# BUCK
|
||||||
|
buck-out/
|
||||||
|
\.buckd/
|
||||||
|
*.keystore
|
||||||
|
|
||||||
|
# fastlane
|
||||||
|
#
|
||||||
|
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||||
|
# screenshots whenever they are needed.
|
||||||
|
# For more information about the recommended setup visit:
|
||||||
|
# https://docs.fastlane.tools/best-practices/source-control/
|
||||||
|
|
||||||
|
*/fastlane/report.xml
|
||||||
|
*/fastlane/Preview.html
|
||||||
|
*/fastlane/screenshots
|
||||||
|
|
||||||
|
# Bundle artifact
|
||||||
|
*.jsbundle
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
[
|
{
|
||||||
"@types/jest",
|
"@types/jest": "latest",
|
||||||
"@types/react",
|
"@types/react-native": "latest",
|
||||||
"@types/react-native",
|
"@types/react-test-renderer": "latest",
|
||||||
"@types/react-test-renderer",
|
"@types/react": "latest",
|
||||||
"react-native-typescript-transformer",
|
"ts-jest": "latest",
|
||||||
"ts-jest",
|
"typescript": "latest"
|
||||||
"typescript"
|
}
|
||||||
]
|
|
||||||
@@ -1,15 +1,8 @@
|
|||||||
{
|
{
|
||||||
"transform": {
|
"transform": {
|
||||||
"^.+\\.tsx?$": "ts-jest"
|
"^.+\\.tsx?$": "ts-jest"
|
||||||
},
|
},
|
||||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||||
"moduleFileExtensions": [
|
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
|
||||||
"ts",
|
"modulePaths": ["<rootDir>"]
|
||||||
"tsx",
|
|
||||||
"js",
|
|
||||||
"jsx",
|
|
||||||
"json",
|
|
||||||
"node"
|
|
||||||
],
|
|
||||||
"modulePaths": ["<rootDir>"]
|
|
||||||
}
|
}
|
||||||
Generated
+1646
File diff suppressed because it is too large.
Load diff
+27
-23
@@ -1,25 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-template-typescript",
|
"name": "react-native-template-typescript",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
|
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "npm --no-git-tag-version version from-git"
|
"test": "standard setup.js",
|
||||||
},
|
"prepublishOnly": "npm --no-git-tag-version version $TRAVIS_TAG"
|
||||||
"repository": {
|
},
|
||||||
"type": "git",
|
"repository": {
|
||||||
"url": "git+https://github.com/emin93/react-native-template-typescript.git"
|
"type": "git",
|
||||||
},
|
"url": "git+https://github.com/emin93/react-native-template-typescript.git"
|
||||||
"keywords": [
|
},
|
||||||
"react-native",
|
"keywords": [
|
||||||
"typescript",
|
"react-native",
|
||||||
"jest",
|
"typescript",
|
||||||
"template",
|
"jest",
|
||||||
"boilerplate"
|
"template",
|
||||||
],
|
"boilerplate"
|
||||||
"author": "Emin Khateeb <emin@emin.ch>",
|
],
|
||||||
"license": "MIT",
|
"author": "Emin Khateeb <emin@emin.ch>",
|
||||||
"bugs": {
|
"license": "MIT",
|
||||||
"url": "https://github.com/emin93/react-native-template-typescript/issues"
|
"bugs": {
|
||||||
},
|
"url": "https://github.com/emin93/react-native-template-typescript/issues"
|
||||||
"homepage": "https://github.com/emin93/react-native-template-typescript#readme"
|
},
|
||||||
|
"homepage": "https://github.com/emin93/react-native-template-typescript#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"standard": "12.0.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
getTransformModulePath() {
|
|
||||||
return require.resolve('react-native-typescript-transformer');
|
|
||||||
},
|
|
||||||
getSourceExts() {
|
|
||||||
return ['ts', 'tsx'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +1,24 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs')
|
||||||
const path = require('path');
|
const path = require('path')
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
const packageJson = require('./package.json');
|
const packageJson = require('./package.json')
|
||||||
const jestConfig = require('./jest.json');
|
const jestConfig = require('./jest.json')
|
||||||
const devDependencies = require('./devDependencies.json');
|
|
||||||
|
|
||||||
const deleteFile = (fileName) => {
|
const deleteFile = fileName => fs.unlinkSync(path.join(__dirname, fileName))
|
||||||
const filePath = path.join(process.cwd(), fileName);
|
const writeFile = (fileName, data) => fs.writeFileSync(path.join(__dirname, fileName), data)
|
||||||
|
|
||||||
if (!fs.existsSync(filePath)) {
|
console.log('🔄 Setting up...')
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.unlinkSync(filePath);
|
packageJson.scripts.tsc = 'tsc'
|
||||||
};
|
packageJson.jest = Object.assign(packageJson.jest, jestConfig)
|
||||||
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), fileName), data);
|
|
||||||
const isYarnAvailable = () => {
|
|
||||||
try {
|
|
||||||
execSync('yarn --version', { stdio: 'ignore' });
|
|
||||||
return true;
|
|
||||||
} catch (exc) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const packageManager = isYarnAvailable() ? 'yarn' : 'npm';
|
writeFile('package.json', JSON.stringify(packageJson, null, 2))
|
||||||
const execOptions = { stdio: 'inherit' };
|
|
||||||
|
|
||||||
console.log('🔄 Please wait...\n');
|
deleteFile('.flowconfig')
|
||||||
|
deleteFile('App.js')
|
||||||
|
deleteFile('__tests__/App.js')
|
||||||
|
deleteFile('LICENSE')
|
||||||
|
deleteFile('README.md')
|
||||||
|
deleteFile('setup.js')
|
||||||
|
|
||||||
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js`;
|
console.log(`✅ Setup completed!`)
|
||||||
packageJson.jest = Object.assign(packageJson.jest, jestConfig);
|
|
||||||
writeFile('package.json', JSON.stringify(packageJson, null, 2));
|
|
||||||
|
|
||||||
console.log(`📦 Installing dependencies with ${packageManager}...\n`);
|
|
||||||
|
|
||||||
switch (packageManager) {
|
|
||||||
case 'yarn':
|
|
||||||
execSync(`yarn add ${devDependencies.join(' ')} --dev --exact`, execOptions);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
execSync(`npm i ${devDependencies.join(' ')} --save-dev --save-exact`, execOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteFile('App.js');
|
|
||||||
deleteFile('__tests__/App.js');
|
|
||||||
deleteFile('.flowconfig');
|
|
||||||
deleteFile('devDependencies.json');
|
|
||||||
deleteFile('jest.json');
|
|
||||||
deleteFile('README.md');
|
|
||||||
deleteFile('LICENSE');
|
|
||||||
deleteFile('setup.js');
|
|
||||||
|
|
||||||
console.log(`\n✅ Setup completed! You can now start with: ${packageManager} start\n`);
|
|
||||||
+13
-12
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2015",
|
"allowJs": true,
|
||||||
"jsx": "react",
|
"allowSyntheticDefaultImports": true,
|
||||||
"noEmit": true,
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "node",
|
"isolatedModules": true,
|
||||||
"noImplicitAny": true,
|
"jsx": "react",
|
||||||
"allowSyntheticDefaultImports": true,
|
"lib": ["es6"],
|
||||||
"esModuleInterop": true
|
"moduleResolution": "node",
|
||||||
},
|
"noEmit": true,
|
||||||
"exclude": [
|
"strict": true,
|
||||||
"node_modules"
|
"target": "esnext"
|
||||||
]
|
},
|
||||||
|
"exclude": ["node_modules", "babel.config.js"]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user