Compare commits

..
13 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
Emin Khateeb eff79f6d54 Merge pull request #12 from emin93/emin93-patch-1
Update setup.js
2018-04-10 12:18:34 +02:00
Emin Khateeb d3f6c2e173 Update setup.js
Fixed issue which caused the setup script when trying to delete non-existing files.
2018-04-10 12:17:03 +02:00
10 changed files with 2043 additions and 108 deletions

No files matched your search

+3 -1
View File
@@ -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
+3 -3
View File
@@ -6,7 +6,7 @@
* https://github.com/emin93/react-native-template-typescript * https://github.com/emin93/react-native-template-typescript
*/ */
import React from 'react'; import React, { Component } from 'react';
import { import {
Platform, Platform,
StyleSheet, StyleSheet,
@@ -21,8 +21,8 @@ const instructions = Platform.select({
'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 React.Component<Props> { export default class App extends Component<Props> {
render() { render() {
return ( return (
<View style={styles.container}> <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. 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 ## :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)
+7 -7
View File
@@ -1,9 +1,9 @@
[ [
"@types/jest", "@types/jest",
"@types/react", "@types/react",
"@types/react-native", "@types/react-native",
"@types/react-test-renderer", "@types/react-test-renderer",
"react-native-typescript-transformer", "react-native-typescript-transformer",
"ts-jest", "ts-jest",
"typescript" "typescript"
] ]
+13 -13
View File
@@ -1,15 +1,15 @@
{ {
"transform": { "transform": {
"^.+\\.tsx?$": "ts-jest" "^.+\\.tsx?$": "ts-jest"
}, },
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [ "moduleFileExtensions": [
"ts", "ts",
"tsx", "tsx",
"js", "js",
"jsx", "jsx",
"json", "json",
"node" "node"
], ],
"modulePaths": ["<rootDir>"] "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", "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": "git reset --hard && npm --no-git-tag-version version from-git"
"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": "11.0.1"
}
} }
+7 -7
View File
@@ -1,8 +1,8 @@
module.exports = { module.exports = {
getTransformModulePath() { getTransformModulePath() {
return require.resolve('react-native-typescript-transformer'); return require.resolve('react-native-typescript-transformer');
}, },
getSourceExts() { getSourceExts() {
return ['ts', 'tsx']; return ['ts', 'tsx'];
} },
} };
+49 -42
View File
@@ -1,48 +1,55 @@
const fs = require('fs'); const fs = require('fs')
const path = require('path'); const path = require('path')
const { execSync } = require('child_process'); 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 devDependencies = require('./devDependencies.json')
const deleteFile = (fileName) => fs.unlinkSync(path.join(process.cwd(), fileName)); const deleteFile = (fileName) => {
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), fileName), data); const filePath = path.join(process.cwd(), fileName)
if (!fs.existsSync(filePath)) {
return
}
fs.unlinkSync(filePath)
}
const writeFile = (fileName, data) => fs.writeFileSync(path.join(process.cwd(), fileName), data)
const isYarnAvailable = () => { const isYarnAvailable = () => {
try { try {
execSync('yarn --version', { stdio: 'ignore' }); execSync('yarn --version', {stdio: 'ignore'})
return true; return true
} catch (exc) { } catch (exc) {
return false; 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);
} }
deleteFile('App.js'); const packageManager = isYarnAvailable() ? 'yarn' : 'npm'
deleteFile('__tests__/App.js'); const execOptions = {stdio: 'inherit'}
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`); 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": { "compilerOptions": {
"target": "es2015", "allowSyntheticDefaultImports": true,
"jsx": "react", "esModuleInterop": true,
"noEmit": true, "jsx": "react",
"moduleResolution": "node", "module": "es6",
"noImplicitAny": true, "moduleResolution": "node",
"allowSyntheticDefaultImports": true, "noEmit": true,
"esModuleInterop": true "noImplicitAny": true,
}, "target": "es6"
"exclude": [ },
"node_modules" "exclude": ["node_modules"]
]
} }