Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76c70cf207 | ||
|
|
d727d3c7e6 | ||
|
|
eae5bed476 | ||
|
|
94c175664a | ||
|
|
98c6517801 | ||
|
|
9e832e69c6 | ||
|
|
93b8ef0173 | ||
|
|
604fce0372 | ||
|
|
56a7a57654 | ||
|
|
b009ff628d | ||
|
|
f770415db3 | ||
|
|
88a5fc6ad6 | ||
|
|
049943c7bd | ||
|
|
990f52d702 | ||
|
|
76e0acdb31 | ||
|
|
7947ef1d36 | ||
|
|
de9d3f0804 | ||
|
|
0ab55f4385 | ||
|
|
0b54ba54c6 | ||
|
|
9d2f745914 | ||
|
|
651d111624 | ||
|
|
cbe99e2b0f | ||
|
|
fdcc07aa80 | ||
|
|
2376f89dcc | ||
|
|
5706e87500 | ||
|
|
12ed73a490 | ||
|
|
5635eb9106 | ||
|
|
5a8cf6bbe6 | ||
|
|
8e588cf4b5 | ||
|
|
5ce07d7e6c | ||
|
|
33cc106144 | ||
|
|
add36b1f30 | ||
|
|
2c6b757051 | ||
|
|
65ac7f1bbf | ||
|
|
c9184ffc06 | ||
|
|
1bed694429 | ||
|
|
e2b4039a30 | ||
|
|
f8369603f4 | ||
|
|
2433c22b3d | ||
|
|
a332cb68f4 | ||
|
|
ffc9af3595 | ||
|
|
ea456ca75d | ||
|
|
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 |
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/
|
||||
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
|
||||
.vscode/
|
||||
+13
-9
@@ -1,13 +1,17 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "node"
|
||||
cache:
|
||||
directories:
|
||||
- "node_modules"
|
||||
deploy:
|
||||
on:
|
||||
tags: true
|
||||
provider: npm
|
||||
email: "emin@emin.ch"
|
||||
api_key: "${NPM_TOKEN}"
|
||||
skip_cleanup: true
|
||||
- provider: npm
|
||||
on:
|
||||
condition: $TRAVIS_BRANCH == "master" && -n $TRAVIS_TAG
|
||||
email: "emin@emin.ch"
|
||||
api_key: "${NPM_TOKEN}"
|
||||
skip_cleanup: true
|
||||
- provider: npm
|
||||
on:
|
||||
condition: $TRAVIS_BRANCH == "master-cli-v2" && -n $TRAVIS_TAG
|
||||
email: "emin@emin.ch"
|
||||
api_key: "${NPM_TOKEN}"
|
||||
skip_cleanup: true
|
||||
tag: next
|
||||
@@ -1,60 +1,118 @@
|
||||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
*
|
||||
*
|
||||
* Generated with the TypeScript template
|
||||
* https://github.com/emin93/react-native-template-typescript
|
||||
* https://github.com/react-native-community/react-native-template-typescript
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import React, {Fragment} from 'react';
|
||||
import {
|
||||
Platform,
|
||||
SafeAreaView,
|
||||
StyleSheet,
|
||||
ScrollView,
|
||||
View,
|
||||
Text,
|
||||
View
|
||||
StatusBar,
|
||||
} from 'react-native';
|
||||
|
||||
const instructions = Platform.select({
|
||||
ios: 'Press Cmd+R to reload,\n' +
|
||||
'Cmd+D or shake for dev menu',
|
||||
android: 'Double tap R on your keyboard to reload,\n' +
|
||||
'Shake or press menu button for dev menu',
|
||||
});
|
||||
import {
|
||||
Header,
|
||||
LearnMoreLinks,
|
||||
Colors,
|
||||
DebugInstructions,
|
||||
ReloadInstructions,
|
||||
} from 'react-native/Libraries/NewAppScreen';
|
||||
|
||||
interface Props {}
|
||||
export default class App extends Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit App.tsx
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
{instructions}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
const App = () => {
|
||||
const usingHermes = typeof HermesInternal === 'object' && HermesInternal !== null;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<StatusBar barStyle="dark-content" />
|
||||
<SafeAreaView>
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
style={styles.scrollView}>
|
||||
<Header />
|
||||
{!usingHermes ? null : (
|
||||
<View style={styles.engine}>
|
||||
<Text style={styles.footer}>Engine: Hermes</Text>
|
||||
</View>
|
||||
)}
|
||||
<View style={styles.body}>
|
||||
<View style={styles.sectionContainer}>
|
||||
<Text style={styles.sectionTitle}>Step One</Text>
|
||||
<Text style={styles.sectionDescription}>
|
||||
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
|
||||
screen and then come back to see your edits.
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.sectionContainer}>
|
||||
<Text style={styles.sectionTitle}>See Your Changes</Text>
|
||||
<Text style={styles.sectionDescription}>
|
||||
<ReloadInstructions />
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.sectionContainer}>
|
||||
<Text style={styles.sectionTitle}>Debug</Text>
|
||||
<Text style={styles.sectionDescription}>
|
||||
<DebugInstructions />
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.sectionContainer}>
|
||||
<Text style={styles.sectionTitle}>Learn More</Text>
|
||||
<Text style={styles.sectionDescription}>
|
||||
Read the docs to discover what to do next:
|
||||
</Text>
|
||||
</View>
|
||||
<LearnMoreLinks />
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
scrollView: {
|
||||
backgroundColor: Colors.lighter,
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
engine: {
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
body: {
|
||||
backgroundColor: Colors.white,
|
||||
},
|
||||
sectionContainer: {
|
||||
marginTop: 32,
|
||||
paddingHorizontal: 24,
|
||||
},
|
||||
sectionTitle: {
|
||||
fontSize: 24,
|
||||
fontWeight: '600',
|
||||
color: Colors.black,
|
||||
},
|
||||
sectionDescription: {
|
||||
marginTop: 8,
|
||||
fontSize: 18,
|
||||
fontWeight: '400',
|
||||
color: Colors.dark,
|
||||
},
|
||||
highlight: {
|
||||
fontWeight: '700',
|
||||
},
|
||||
footer: {
|
||||
color: Colors.dark,
|
||||
fontSize: 12,
|
||||
fontWeight: '600',
|
||||
padding: 4,
|
||||
paddingRight: 12,
|
||||
textAlign: 'right',
|
||||
},
|
||||
});
|
||||
|
||||
export default App;
|
||||
+3
-7
@@ -1,11 +1,11 @@
|
||||
# Contributing
|
||||
|
||||
Cool, I'm glad you decided to contribute to React Native Template TypeScript.
|
||||
|
||||
Don't worry, I won't bother you with thousands of rules. I want to make contributing to this project as easy and transparent as possible.
|
||||
Contributing to this project should be as easy and transparent as possible.
|
||||
|
||||
## Workflow
|
||||
|
||||
Right now there are two master branches in order to keep support for the old React Native CLI (for more info, check out the [related issue](https://github.com/react-native-community/react-native-template-typescript/issues/39)).
|
||||
|
||||
We use [GitHub Flow](https://guides.github.com/introduction/flow/), so all code changes happen through pull requests.
|
||||
|
||||
1. Fork the repository and create your branch from `master`.
|
||||
@@ -15,7 +15,3 @@ We use [GitHub Flow](https://guides.github.com/introduction/flow/), so all code
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the [MIT License](https://choosealicense.com/licenses/mit/).
|
||||
|
||||
## Code style
|
||||
|
||||
Currently there is no lint configuration, but you should try to stay consistent with the existing code.
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Emin Khateeb
|
||||
Copyright (c) 2019 Emin Khateeb
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,80 +1,46 @@
|
||||
# :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
|
||||
|
||||
Clean and minimalist React Native template for a quick start with TypeScript.
|
||||
<p>
|
||||
<a href="https://travis-ci.org/react-native-community/react-native-template-typescript">
|
||||
<img alt="Build Status" src="https://img.shields.io/travis/react-native-community/react-native-template-typescript.svg" target="_blank" />
|
||||
</a>
|
||||
<a href="https://github.com/react-native-community/react-native-template-typescript#readme">
|
||||
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" target="_blank" />
|
||||
</a>
|
||||
<a href="https://github.com/react-native-community/react-native-template-typescript/graphs/commit-activity">
|
||||
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" target="_blank" />
|
||||
</a>
|
||||
<a href="https://github.com/react-native-community/react-native-template-typescript/blob/master/LICENSE">
|
||||
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" target="_blank" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[](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.
|
||||
> Clean and minimalist React Native template for a quick start with TypeScript.
|
||||
|
||||
## :star: Features
|
||||
|
||||
- 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:
|
||||
- Elegant usage directly within the [React Native CLI](https://github.com/react-native-community/cli)
|
||||
- Consistent with the default React Native template
|
||||
- Minimal additional dependencies
|
||||
|
||||
## :arrow_forward: Quick Start
|
||||
## :arrow_forward: Usage
|
||||
|
||||
### React Native >= 0.60
|
||||
|
||||
```sh
|
||||
npx react-native init MyApp --template react-native-template-typescript@next
|
||||
```
|
||||
|
||||
### React Native <= 0.59
|
||||
|
||||
```sh
|
||||
react-native init MyApp --template typescript
|
||||
cd MyApp
|
||||
node setup.js
|
||||
```
|
||||
|
||||
## :question: FAQ
|
||||
|
||||
### 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)
|
||||
|
||||
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.
|
||||
|
||||
Lots of :heart: and credits to the owners and maintainers of those packages.
|
||||
|
||||
### 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.
|
||||
|
||||
### How will this template affect the React Native CLI workflow?
|
||||
|
||||
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)
|
||||
|
||||
## :computer: Contributing
|
||||
|
||||
Contributions are very welcome. Please check out the [contributing document](https://github.com/emin93/react-native-template-typescript/blob/master/CONTRIBUTING.md).
|
||||
Contributions are very welcome. Please check out the [contributing document](CONTRIBUTING.md).
|
||||
|
||||
### Donations
|
||||
## :bookmark: License
|
||||
|
||||
I created this project in my spare time because I enjoy coding. Of course you can support me by [buying me a coffee](https://www.paypal.me/emin93) if you wish. :coffee: :relieved:
|
||||
This project is [MIT](LICENSE) licensed.
|
||||
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
import 'react-native';
|
||||
import React from 'react';
|
||||
import App from '../App';
|
||||
@@ -6,7 +10,5 @@ import App from '../App';
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer.create(
|
||||
<App />
|
||||
);
|
||||
});
|
||||
renderer.create(<App />);
|
||||
});
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
# 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
|
||||
|
||||
# CocoaPods
|
||||
/ios/Pods/
|
||||
@@ -1,9 +1,7 @@
|
||||
[
|
||||
"@types/jest",
|
||||
"@types/react",
|
||||
"@types/react-native",
|
||||
"@types/react-test-renderer",
|
||||
"react-native-typescript-transformer",
|
||||
"ts-jest",
|
||||
"typescript"
|
||||
]
|
||||
{
|
||||
"@types/jest": "latest",
|
||||
"@types/react-native": "latest",
|
||||
"@types/react-test-renderer": "latest",
|
||||
"@types/react": "latest",
|
||||
"typescript": "latest"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'react-native',
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"transform": {
|
||||
"^.+\\.tsx?$": "ts-jest"
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"moduleFileExtensions": [
|
||||
"ts",
|
||||
"tsx",
|
||||
"js",
|
||||
"jsx",
|
||||
"json",
|
||||
"node"
|
||||
],
|
||||
"modulePaths": ["<rootDir>"]
|
||||
}
|
||||
Generated
+728
-817
File diff suppressed because it is too large.
Load diff
+3
-2
@@ -4,7 +4,8 @@
|
||||
"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"
|
||||
"prepublishOnly": "npm --no-git-tag-version version $TRAVIS_TAG",
|
||||
"install": "node setup.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,6 +25,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/emin93/react-native-template-typescript#readme",
|
||||
"devDependencies": {
|
||||
"standard": "11.0.1"
|
||||
"standard": "13.0.2"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
module.exports = {
|
||||
getTransformModulePath() {
|
||||
return require.resolve('react-native-typescript-transformer');
|
||||
},
|
||||
getSourceExts() {
|
||||
return ['ts', 'tsx'];
|
||||
},
|
||||
};
|
||||
@@ -1,55 +1,25 @@
|
||||
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')
|
||||
if (fs.existsSync(path.join(__dirname, '.travis.yml'))) {
|
||||
process.exit()
|
||||
}
|
||||
|
||||
const deleteFile = (fileName) => {
|
||||
const filePath = path.join(process.cwd(), fileName)
|
||||
const projectFilesToDelete = ['.flowconfig', 'App.js', '__tests__/App-test.js']
|
||||
|
||||
const templateFilesToDelete = ['setup.js', 'README.md', 'LICENSE']
|
||||
|
||||
const deleteFile = filePath => {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return
|
||||
}
|
||||
|
||||
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'}
|
||||
const projectPath = path.join(__dirname, '..', '..')
|
||||
const deleteProjectFile = fileName => deleteFile(path.join(projectPath, fileName))
|
||||
const deleteTemplateFile = fileName => deleteFile(path.join(__dirname, fileName))
|
||||
|
||||
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`)
|
||||
projectFilesToDelete.forEach(deleteProjectFile)
|
||||
templateFilesToDelete.forEach(deleteTemplateFile)
|
||||
+6
-4
@@ -1,13 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react",
|
||||
"module": "es6",
|
||||
"lib": ["es6"],
|
||||
"moduleResolution": "node",
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"target": "es6"
|
||||
"strict": true,
|
||||
"target": "esnext"
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
|
||||
}
|
||||
Reference in new issue
Block a user