-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare.app.config.ts
159 lines (145 loc) · 5 KB
/
prepare.app.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import fs from 'fs';
import settings from './src/settings';
import { ExpoConfig } from 'expo/config';
import myPackage from './package.json';
const appInputs = {
platform: process.env.EXPO_PLATFORM,
firstTime: process.env.EXPO_FIRST_TIME,
nodeEnv: process.env.NODE_ENV,
expoNodeEnv: process.env.EXPO_NODE_ENV,
};
console.log('appInputs', appInputs);
let slug = settings.config.tonomyIdSlug.replace('://', '');
const scheme = slug;
console.log('scheme', scheme);
if (appInputs.platform === 'ios' && appInputs.expoNodeEnv === 'staging') {
console.log('Replacing config for demo with some staging config (iOS only');
// Deploy staging and testnet ios app to the same app store listing
const config = require('./src/config/config.staging.json');
// Expo slug, and bundleIdentifier must be the same for the same app store listing
slug = config.appName.toLowerCase().replace(/ /g, '-');
// Match the projectId of staging to make the same build
settings.config.expoProjectId = config.expoProjectId;
}
if (appInputs.platform === 'ios' && appInputs.expoNodeEnv === 'testnet') {
console.log('Replacing config for demo with some testnet config (iOS only');
// Deploy staging and testnet ios app to the same app store listing
const config = require('./src/config/config.testnet.json');
// Expo slug, and bundleIdentifier must be the same for the same app store listing
slug = config.appName.toLowerCase().replace(/ /g, '-');
// Match the projectId of staging to make the same build
settings.config.expoProjectId = config.expoProjectId;
}
const identifier = 'foundation.tonomy.projects.' + slug.replace(/-/g, '');
// Check if inputs are correct
if (!/^[0-9a-zA-Z ]+$/g.test(settings.config.appName)) throw new Error('Invalid app name ' + settings.config.appName);
if (!/^([.]{1})([0-9a-z.]+)$/g.test(settings.config.accountSuffix))
throw new Error('Invalid account suffix ' + settings.config.accountSuffix);
const expo: ExpoConfig = {
scheme,
name: settings.config.appName,
slug,
version: myPackage.version,
orientation: 'portrait',
icon: settings.config.images.logo1024,
userInterfaceStyle: 'light',
splash: {
image: settings.config.images.splash,
resizeMode: 'contain',
backgroundColor: '#ffffff',
},
updates: {
fallbackToCacheTimeout: 0,
},
githubUrl: 'https://github.com/Tonomy-Foundation/Tonomy-ID',
assetBundlePatterns: ['**/*'],
ios: {
supportsTablet: true,
bundleIdentifier: identifier,
infoPlist: {
NSCameraUsageDescription: 'We need access to your camera to scan the QR code.',
LSApplicationQueriesSchemes: ['esr', 'wc', 'did'],
CFBundleURLTypes: [
{
CFBundleURLSchemes: ['esr', 'wc', 'did'],
},
],
},
},
android: {
allowBackup: false,
package: identifier,
intentFilters: [
{
action: 'VIEW',
data: [
{
scheme: 'esr',
},
{
scheme: 'wc',
},
{
scheme: 'did',
},
],
category: ['BROWSABLE', 'DEFAULT'],
},
],
},
web: {
favicon: settings.config.images.logo48,
},
plugins: [
[
'expo-notifications',
{
icon: settings.config.images.logo1024,
color: settings.config.theme.primaryColor,
},
],
[
'expo-build-properties',
{
android: {
compileSdkVersion: 34,
targetSdkVersion: 34,
buildToolsVersion: '34.0.0',
},
ios: {
deploymentTarget: '13.4',
},
},
],
['./android.manifest.plugin.js'],
[
'@sentry/react-native/expo',
{
organization: 'tonomy-foundation-ba',
project: settings.config.sentryProjectId,
url: 'https://sentry.io/',
},
],
],
extra: {
eas: {
projectId: settings.config.expoProjectId,
},
EXPO_NODE_ENV: process.env.EXPO_NODE_ENV,
DEBUG: process.env.DEBUG,
},
};
if (!['development', 'designonly'].includes(settings.env)) {
console.log('Replacing expoProjectId');
if (!expo.extra) expo.extra = {};
if (!expo.extra.eas) expo.extra.eas = {};
expo.extra.eas.projectId = settings.config.expoProjectId;
}
if (process.env.EXPO_FIRST_TIME === 'true') {
console.log('Setting up expo for the first time');
// @ts-expect-error expo.extra is possibly not defined
expo.extra.eas = {};
}
console.log(JSON.stringify(expo, null, 2));
// Write app.json
fs.writeFileSync('./app.json', JSON.stringify({ expo }, null, 2));