Compare commits

..
11 Commits
Author SHA1 Message Date
Emin Khateeb ec3a826edc Update README.md
added new solution for debugging
2018-06-06 17:28:42 +02:00
Emin Khateeb a585faa237 Update tsconfig.json
re-ordered members alphabetically and added module option
2018-06-06 17:09:01 +02:00
Emin Khateeb 919ebb922e Update setup.js
removed start script config parameter as it seems to work just fine without
2018-06-06 17:05:20 +02:00
Emin Khateeb 57233a492b fixed issue with new deployment 2018-04-24 21:25:57 +02:00
Emin Khateeb b8f4b89aca now caching node modules 2018-04-24 21:18:36 +02:00
Emin Khateeb 80e970bda8 added standardjs to lint the setup.js and now using consistently 2 spaces indent 2018-04-24 21:14:46 +02:00
Emin Khateeb dc432eea2d Update App.tsx
removed unnecessary semicolon
2018-04-20 11:34:35 +02:00
Emin Khateeb 8c5248b2b3 Merge pull request #15 from emin93/emin93-patch-1
Update README.md
2018-04-10 15:29:42 +02:00
Emin Khateeb 11fa0420ed Update README.md
added link to vs code debugging fix
2018-04-10 15:29:12 +02:00
Emin Khateeb d885abb7ce Merge pull request #14 from emin93/emin93-patch-1
Update App.tsx
2018-04-10 13:12:36 +02:00
Emin Khateeb fbe903ad81 Update App.tsx 2018-04-10 13:09:24 +02:00
10 changed files with 2040 additions and 113 deletions

No files matched your search

+3 -1
View File
@@ -1,7 +1,9 @@
language: node_js
node_js:
- "node"
install: true
cache:
directories:
- "node_modules"
deploy:
on:
tags: true
+3 -3
View File
@@ -6,7 +6,7 @@
* https://github.com/emin93/react-native-template-typescript
*/
import React from 'react';
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
@@ -21,8 +21,8 @@ const instructions = Platform.select({
'Shake or press menu button for dev menu',
});
interface Props {};
export default class App extends React.Component<Props> {
interface Props {}
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
+24
View File
@@ -43,6 +43,30 @@ 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.
### Does debugging work too?
Yes it does, but you need to enable the `sourceMap` option in the `tsconfig.json`.
Make sure it looks something like this:
```json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "react",
"module": "es6",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": true,
"target": "es6",
"sourceMap": true
},
"exclude": ["node_modules"]
}
```
This is not enabled by default as it is unknown if it has any negative effects on the transpilation time. For more information make sure to check out the [post by Nicolas Hémonic](https://medium.com/@NicolasHemonic/hi-mo-mac-d18286202602).
## :globe_with_meridians: Links
- ["Using React Native with TypeScript just became simple" on Medium](https://medium.com/@emin93/react-native-typescript-b965059109d3)
+7 -7
View File
@@ -1,9 +1,9 @@
[
"@types/jest",
"@types/react",
"@types/react-native",
"@types/react-test-renderer",
"react-native-typescript-transformer",
"ts-jest",
"typescript"
"@types/jest",
"@types/react",
"@types/react-native",
"@types/react-test-renderer",
"react-native-typescript-transformer",
"ts-jest",
"typescript"
]
+13 -13
View File
@@ -1,15 +1,15 @@
{
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"modulePaths": ["<rootDir>"]
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"modulePaths": ["<rootDir>"]
}
+1899
View File
File diff suppressed because it is too large. Load diff
+27 -23
View File
@@ -1,25 +1,29 @@
{
"name": "react-native-template-typescript",
"version": "0.0.1",
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
"scripts": {
"prepublishOnly": "npm --no-git-tag-version version from-git"
},
"repository": {
"type": "git",
"url": "git+https://github.com/emin93/react-native-template-typescript.git"
},
"keywords": [
"react-native",
"typescript",
"jest",
"template",
"boilerplate"
],
"author": "Emin Khateeb <emin@emin.ch>",
"license": "MIT",
"bugs": {
"url": "https://github.com/emin93/react-native-template-typescript/issues"
},
"homepage": "https://github.com/emin93/react-native-template-typescript#readme"
"name": "react-native-template-typescript",
"version": "0.0.1",
"description": "Clean and minimalist React Native template for a quick start with TypeScript.",
"scripts": {
"test": "standard setup.js",
"prepublishOnly": "git reset --hard && npm --no-git-tag-version version from-git"
},
"repository": {
"type": "git",
"url": "git+https://github.com/emin93/react-native-template-typescript.git"
},
"keywords": [
"react-native",
"typescript",
"jest",
"template",
"boilerplate"
],
"author": "Emin Khateeb <emin@emin.ch>",
"license": "MIT",
"bugs": {
"url": "https://github.com/emin93/react-native-template-typescript/issues"
},
"homepage": "https://github.com/emin93/react-native-template-typescript#readme",
"devDependencies": {
"standard": "11.0.1"
}
}
+7 -7
View File
@@ -1,8 +1,8 @@
module.exports = {
getTransformModulePath() {
return require.resolve('react-native-typescript-transformer');
},
getSourceExts() {
return ['ts', 'tsx'];
}
}
getTransformModulePath() {
return require.resolve('react-native-typescript-transformer');
},
getSourceExts() {
return ['ts', 'tsx'];
},
};
+46 -47
View File
@@ -1,56 +1,55 @@
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const fs = require('fs')
const path = require('path')
const {execSync} = require('child_process')
const packageJson = require('./package.json');
const jestConfig = require('./jest.json');
const devDependencies = require('./devDependencies.json');
const packageJson = require('./package.json')
const jestConfig = require('./jest.json')
const devDependencies = require('./devDependencies.json')
const deleteFile = (fileName) => {
const filePath = path.join(process.cwd(), fileName);
const filePath = path.join(process.cwd(), fileName)
if (!fs.existsSync(filePath)) {
return;
}
if (!fs.existsSync(filePath)) {
return
}
fs.unlinkSync(filePath);
};
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), fileName), data);
fs.unlinkSync(filePath)
}
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';
const execOptions = { stdio: 'inherit' };
console.log('🔄 Please wait...\n');
packageJson.scripts.start = `${packageJson.scripts.start} --config ../../../../rn-cli.config.js`;
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);
try {
execSync('yarn --version', {stdio: 'ignore'})
return true
} catch (exc) {
return false
}
}
deleteFile('App.js');
deleteFile('__tests__/App.js');
deleteFile('.flowconfig');
deleteFile('devDependencies.json');
deleteFile('jest.json');
deleteFile('README.md');
deleteFile('LICENSE');
deleteFile('setup.js');
const packageManager = isYarnAvailable() ? 'yarn' : 'npm'
const execOptions = {stdio: 'inherit'}
console.log(`\n✅ Setup completed! You can now start with: ${packageManager} start\n`);
console.log('🔄 Please wait...\n')
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`)
+11 -12
View File
@@ -1,14 +1,13 @@
{
"compilerOptions": {
"target": "es2015",
"jsx": "react",
"noEmit": true,
"moduleResolution": "node",
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"exclude": [
"node_modules"
]
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "react",
"module": "es6",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": true,
"target": "es6"
},
"exclude": ["node_modules"]
}