Skip to content

Commit 295ec6e

Browse files
committed
React native skeleton generator
0 parents  commit 295ec6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+8808
-0
lines changed

.gitignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
target/
9+
*.pbxuser
10+
!default.pbxuser
11+
*.mode1v3
12+
!default.mode1v3
13+
*.mode2v3
14+
!default.mode2v3
15+
*.perspectivev3
16+
!default.perspectivev3
17+
xcuserdata
18+
*.xccheckout
19+
*.moved-aside
20+
DerivedData
21+
*.hmap
22+
*.ipa
23+
*.xcuserstate
24+
project.xcworkspace
25+
26+
# Android/IntelliJ
27+
#
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
50+
51+
fastlane/report.xml
52+
fastlane/Preview.html
53+
fastlane/screenshots

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
boilerplate/target
3+
boilerplate/node_modules
4+
boilerplate/.jest

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: node_js
2+
node_js:
3+
- "node"
4+
install:
5+
- yarn install
6+
deploy:
7+
provider: npm
8+
email: $NPM_EMAIL
9+
api_key: $NPM_TOKEN
10+
on:
11+
tags: true
12+
all_branches: true

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# react-native-generator
2+
React Native Boilerplate Generator
3+
4+
## Install
5+
```
6+
> npm i -g react-native-generator
7+
```
8+
9+
### Create new Project
10+
11+
```
12+
> react-native-generator
13+
```
14+
15+
Provide app name and package

bin/cli.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env node
2+
3+
const path = require('path');
4+
const replace = require('replace');
5+
const execSync = require('child_process').execSync;
6+
const readline = require('readline');
7+
const fse = require('fs-extra');
8+
9+
const PROJECT_NAME = "XX_PROJECT_NAME_XX";
10+
const APP_ID = "XX_APPLICATION_ID_XX";
11+
const ANDROID_SRC_PATH = 'android/app/src/main/java/';
12+
const BOILERPLATE_DIR = path.join(__dirname, '..', 'boilerplate');
13+
14+
const replaceInProject = (oldStr, newStr, appDir) => {
15+
replace({
16+
regex: oldStr,
17+
replacement: newStr,
18+
paths: [appDir],
19+
recursive: true,
20+
silent: true,
21+
exclude: 'generator.js'
22+
});
23+
};
24+
25+
const generate = function (appName, appId) {
26+
const appDir = `${process.cwd()}/${appName}/`;
27+
fse.mkdirsSync(appDir);
28+
fse.copySync(BOILERPLATE_DIR, appDir, {
29+
filter: (src, dest) => {
30+
return src.indexOf('node_modules') === -1;
31+
}
32+
});
33+
34+
console.log('Setting Project Name(MyAwesomeApp): ' + appName);
35+
replaceInProject(PROJECT_NAME, appName, appDir);
36+
37+
console.log('Setting App Identifier: ' + appId);
38+
replaceInProject(APP_ID, appId, appDir);
39+
40+
console.log('Setting Project Folder:' + appName);
41+
const renamerCli = path.join(__dirname, '..', 'node_modules/renamer/bin/cli.js');
42+
const command = `${renamerCli} --find '${PROJECT_NAME}' --replace '${appName}' '${appDir}**'`;
43+
execSync(command);
44+
45+
console.log('Copying Android Source files');
46+
const fullPath = appDir + ANDROID_SRC_PATH + appId.split('.').join('/');
47+
fse.mkdirsSync(fullPath);
48+
fse.moveSync(`${appDir}${ANDROID_SRC_PATH}${APP_ID}`, fullPath, {overwrite: true});
49+
50+
console.log('Created Project at ' + appDir);
51+
};
52+
53+
54+
const rl = readline.createInterface({
55+
input: process.stdin,
56+
output: process.stdout
57+
});
58+
59+
rl.question('\nApp Name: ', (appName) => {
60+
rl.question('\nApp Identifier: ', (appId) => {
61+
generate(appName, appId);
62+
63+
rl.close();
64+
});
65+
});
66+

boilerplate/.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["react-native"],
3+
"plugins": [
4+
["module-resolver", {
5+
"root": ["./src/main", "./src/test"]
6+
}]
7+
]
8+
}

boilerplate/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

boilerplate/.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 2
12+
13+
[*.gradle]
14+
indent_size = 4

boilerplate/.eslintrc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": [
3+
"airbnb",
4+
"plugin:flowtype/recommended"
5+
],
6+
"plugins": [
7+
"react-native",
8+
"flowtype"
9+
],
10+
"rules": {
11+
"max-len": ["error", 140],
12+
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],
13+
"react/forbid-prop-types": [0],
14+
"class-methods-use-this": 0,
15+
"global-require": 0
16+
},
17+
"settings": {
18+
"import/resolver": {
19+
"babel-module": {}
20+
}
21+
},
22+
"globals": {
23+
"require": false,
24+
"jest": false,
25+
"it": false,
26+
"describe": false,
27+
"expect": false,
28+
"__DEV__": false
29+
}
30+
}

boilerplate/.flowconfig

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore templates for 'react-native init'
6+
.*/local-cli/templates/.*
7+
8+
; Ignore the website subdir
9+
<PROJECT_ROOT>/website/.*
10+
11+
; Ignore the Dangerfile
12+
<PROJECT_ROOT>/danger/dangerfile.js
13+
14+
; Ignore "BUCK" generated dirs
15+
<PROJECT_ROOT>/\.buckd/
16+
17+
; Ignore unexpected extra "@providesModule"
18+
.*/node_modules/.*/node_modules/fbjs/.*
19+
20+
; Ignore duplicate module providers
21+
; For RN Apps installed via npm, "Libraries" folder is inside
22+
; "node_modules/react-native" but in the source repo it is in the root
23+
.*/Libraries/react-native/React.js
24+
25+
; Ignore polyfills
26+
.*/Libraries/polyfills/.*
27+
28+
[include]
29+
30+
[libs]
31+
node_modules/react-native/Libraries/react-native/react-native-interface.js
32+
node_modules/react-native/flow/
33+
34+
[options]
35+
emoji=true
36+
37+
module.system=haste
38+
39+
munge_underscores=true
40+
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
42+
43+
suppress_type=$FlowIssue
44+
suppress_type=$FlowFixMe
45+
suppress_type=$FixMe
46+
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-1]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-1]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
50+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
51+
52+
unsafe.enable_getters_and_setters=true
53+
54+
[version]
55+
^0.51.0

0 commit comments

Comments
 (0)