@mono-labs/cli 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,71 +1,73 @@
|
|
|
1
|
-
import { spawn } from 'child_process'
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
2
|
|
|
3
|
-
import { program } from '../../app.js'
|
|
4
|
-
import { generateEnvValues } from '../../app.js'
|
|
5
|
-
import { STAGING_URL } from '../../config.js'
|
|
3
|
+
import { program } from '../../app.js';
|
|
4
|
+
import { generateEnvValues } from '../../app.js';
|
|
5
|
+
import { STAGING_URL } from '../../config.js';
|
|
6
6
|
|
|
7
|
-
const allowedPlatforms = ['ios', 'android']
|
|
7
|
+
const allowedPlatforms = ['ios', 'android'];
|
|
8
8
|
function selectPlatform(platform) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (!allowedPlatforms.includes(platform))
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Invalid platform selected, must be one of ${allowedPlatforms.join(', ')}`
|
|
12
|
+
);
|
|
13
|
+
return platform;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
function selectProfile(dev, preview, prod, profile) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (profile && (dev || preview || prod)) {
|
|
18
|
+
throw new Error('Conflict between profile and dev/preview/prod');
|
|
19
|
+
}
|
|
20
|
+
if (dev) return 'development';
|
|
21
|
+
if (preview) return 'preview';
|
|
22
|
+
if (prod) return 'production';
|
|
23
|
+
if (profile) return profile;
|
|
24
|
+
return 'development';
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
program
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
.command('build')
|
|
29
|
+
.description('Execute eas build command')
|
|
30
|
+
.option('-d', 'Build to target development profile')
|
|
31
|
+
.option('-p', 'Build to target preview profile')
|
|
32
|
+
.option('--live', 'Build to target production profile')
|
|
33
|
+
.option('--profile <string>', 'Build profile to use')
|
|
34
|
+
.option('--os, --platform <string>', 'Platform to build', 'ios')
|
|
35
|
+
.option('-f, --force', 'Force build to target production server')
|
|
36
|
+
.action((str, options) => {
|
|
37
|
+
console.log('its me');
|
|
38
|
+
const platform = selectPlatform(str.platform);
|
|
39
|
+
const profile = selectProfile(str.d, str.p, str.live, str.profile);
|
|
40
|
+
const isDev = profile === 'development';
|
|
41
|
+
//console.log(options);
|
|
42
|
+
console.log(`Building ${platform} with profile ${'`'}${profile}${'`'}`);
|
|
43
|
+
console.log('\n\n\n');
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
const EXPO_FORCE_PRODUCTION = str.force || isDev ? 'false' : 'true';
|
|
46
|
+
console.log('EXPO_FORCE_PRODUCTION', EXPO_FORCE_PRODUCTION);
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
let envObj = generateEnvValues(EXPO_FORCE_PRODUCTION, '', false);
|
|
49
|
+
if (!isDev) {
|
|
50
|
+
envObj.EXPO_PUBLIC_API_URL = `${STAGING_URL}`;
|
|
51
|
+
envObj.EXPO_FORCE_PROD = 'true';
|
|
52
|
+
} else {
|
|
53
|
+
const publicUrl = process.env.EXPO_PUBLIC_API_URL || `${STAGING_URL}`;
|
|
54
|
+
envObj.EXPO_PUBLIC_API_URL = publicUrl;
|
|
55
|
+
}
|
|
56
|
+
console.log('envObj', envObj);
|
|
57
|
+
envObj.EAS_BUILD_PROFILE = profile; // your custom variable
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
const command = `mono eas build --profile ${profile} --platform ${platform}`;
|
|
60
|
+
console.log('Running command:', command);
|
|
61
|
+
const child = spawn('yarn', [command], {
|
|
62
|
+
stdio: 'inherit',
|
|
63
|
+
shell: true, // required if using shell-style commands or cross-platform support
|
|
64
|
+
env: {
|
|
65
|
+
...envObj,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
child.on('exit', (code) => {
|
|
70
|
+
console.log(`Process exited with code ${code}`);
|
|
71
|
+
process.exit(code ?? 0);
|
|
72
|
+
});
|
|
73
|
+
});
|