Skip to content

Commit 6635793

Browse files
authored
Merge pull request #14 from TRPGEngine/master
v0.1.5
2 parents b9ec86a + 55822ce commit 6635793

File tree

131 files changed

+2040
-756
lines changed

Some content is hidden

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

131 files changed

+2040
-756
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ config/local.js
66
.sentryclirc
77
.buildcache/
88
build/metro/conf.json
9-
9+
build/emoji/emoji/
10+
android/gradle.properties
1011

1112
# Logs
1213
logs

android/app/build.gradle

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,27 @@ android {
123123
}
124124
}
125125

126-
// // 签名相关
127-
// signingConfigs {
128-
// release {
129-
// storeFile file(MYAPP_RELEASE_STORE_FILE)
130-
// storePassword MYAPP_RELEASE_STORE_PASSWORD
131-
// keyAlias MYAPP_RELEASE_KEY_ALIAS
132-
// keyPassword MYAPP_RELEASE_KEY_PASSWORD
133-
// }
134-
// }
126+
// 签名相关
127+
signingConfigs {
128+
release {
129+
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
130+
storeFile file(MYAPP_RELEASE_STORE_FILE)
131+
storePassword MYAPP_RELEASE_STORE_PASSWORD
132+
keyAlias MYAPP_RELEASE_KEY_ALIAS
133+
keyPassword MYAPP_RELEASE_KEY_PASSWORD
134+
}
135+
}
136+
}
135137

136138
buildTypes {
137139
release {
138140
minifyEnabled enableProguardInReleaseBuilds
139141
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
140-
// signingConfig signingConfigs.release // 使用签名
142+
signingConfig signingConfigs.release // 使用签名
143+
}
144+
145+
debug {
146+
applicationIdSuffix ".test"
141147
}
142148
}
143149
// applicationVariants are e.g. debug, release
@@ -151,11 +157,24 @@ android {
151157
output.versionCodeOverride =
152158
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
153159
}
160+
161+
// 定义输出文件命名
162+
def outputFile = output.outputFile
163+
if (outputFile != null && outputFile.name.endsWith('.apk')) {
164+
def fileName
165+
if (variant.buildType.name.equals('release')) {
166+
fileName = "TRPGEngine-v${defaultConfig.versionName}_${defaultConfig.versionCode}.apk"
167+
} else {
168+
fileName = "TRPGEngine-v${defaultConfig.versionName}-beta.apk"
169+
}
170+
output.apkData.outputFileName = fileName
171+
}
154172
}
155173
}
156174
}
157175

158176
dependencies {
177+
implementation project(':react-native-fast-image')
159178
implementation project(':react-native-webview')
160179
implementation project(':react-native-sentry')
161180
implementation project(':react-native-code-push')

android/app/src/main/java/com/moonrailgun/trpg/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import com.dylanvann.fastimage.FastImageViewPackage;
67
import com.reactnativecommunity.webview.RNCWebViewPackage;
78
import io.sentry.RNSentryPackage;
89
import com.microsoft.codepush.react.CodePush;
@@ -39,6 +40,7 @@ public boolean getUseDeveloperSupport() {
3940
protected List<ReactPackage> getPackages() {
4041
return Arrays.<ReactPackage>asList(
4142
new MainReactPackage(),
43+
new FastImageViewPackage(),
4244
new RNCWebViewPackage(),
4345
new RNSentryPackage(),
4446
new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),

android/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
rootProject.name = 'trpg'
2+
include ':react-native-fast-image'
3+
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
24
include ':react-native-webview'
35
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
46
include ':react-native-sentry'

build/emoji/fetch-github-emoji.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const path = require('path');
2+
const axios = require('axios');
3+
const fs = require('fs-extra');
4+
5+
fs.ensureDir(path.resolve(__dirname, './emoji'));
6+
7+
function fetchEmojiAndSave(name, url) {
8+
return axios
9+
.get(url, {
10+
responseType: 'arraybuffer',
11+
})
12+
.then((res) => {
13+
const data = res.data;
14+
console.log('保存表情:', name);
15+
return fs.outputFile(
16+
path.resolve(__dirname, `./emoji/${name}.png`),
17+
data
18+
);
19+
})
20+
.catch((err) => {
21+
const item = { name, url };
22+
console.error('保存失败:', item);
23+
24+
errorList.push(item);
25+
});
26+
}
27+
28+
const errorList = [];
29+
30+
axios
31+
.get('https://api.github.com/emojis')
32+
.then((res) => {
33+
const data = res.data;
34+
35+
const list = [];
36+
for (const name in data) {
37+
if (data.hasOwnProperty(name)) {
38+
const url = data[name];
39+
40+
list.push(fetchEmojiAndSave(name, url));
41+
}
42+
}
43+
44+
return Promise.all(list);
45+
})
46+
.then((list) => {
47+
console.log(`保存完毕, 共${list.length}个文件, 失败${errorList.length}个`);
48+
49+
fs.outputJson(path.resolve(__dirname, 'errorList.json'), errorList);
50+
});

build/husky/commit-msg.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const fs = require('fs');
2+
const _ = require('lodash');
3+
const commitFile = process.env['HUSKY_GIT_PARAMS'];
4+
const allowScope = require('./lib/allow-scope');
5+
const allowTag = require('./lib/allow-tag');
6+
const re = new RegExp(
7+
`:(${allowTag.join('|')}): \\[(${allowScope.join('|')})\\] .*?`
8+
);
9+
10+
const msg = fs.readFileSync(commitFile, {
11+
encoding: 'utf-8',
12+
});
13+
const firstLine = _.trim(_.head(msg.split('\n')));
14+
const tipCommitFormat = `
15+
${firstLine}
16+
17+
————————————————————
18+
19+
你的提交不合法, 推荐的提交格式:
20+
:tag: [scope] any string
21+
22+
允许的tag:
23+
${allowTag.join(', ')}
24+
允许的scope:
25+
${allowScope.join(', ')}
26+
`;
27+
28+
if (!re.test(firstLine)) {
29+
console.log(tipCommitFormat);
30+
process.exit(1);
31+
}

build/husky/lib/allow-scope.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = ['app', 'web', 'all', 'layout', 'redux'];

build/husky/lib/allow-tag.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = ['star', 'hammer', 'bug', 'fire'];

build/metro/babel-transformer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const getBabelRC = (function() {
4444

4545
// specify babel rc path
4646
let projectBabelRCPath = path.resolve(__dirname, 'babel.config.js');
47+
if (NODE_ENV === 'production') {
48+
projectBabelRCPath = path.resolve(__dirname, 'babel.config.prod.js');
49+
}
4750
console.log('loading babel config:', projectBabelRCPath);
4851
if (fs.existsSync(projectBabelRCPath)) {
4952
babelRC.extends = projectBabelRCPath;

build/metro/babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: [
3+
'module:metro-react-native-babel-preset',
4+
'@babel/preset-typescript',
5+
],
36
plugins: [
47
[
58
'transform-inline-environment-variables',

0 commit comments

Comments
 (0)