beever-create 0.1.4 → 0.1.5
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.
- package/package.json +1 -1
- package/templates/common/assets/README.md +60 -0
- package/templates/common/assets/fonts/Figtree/Figtree-Italic-VariableFont_wght.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/Figtree-VariableFont_wght.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/OFL.txt +93 -0
- package/templates/common/assets/fonts/Figtree/README.txt +77 -0
- package/templates/common/assets/fonts/Figtree/index.ts +27 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-Black.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-BlackItalic.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-Bold.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-BoldItalic.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-ExtraBold.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-ExtraBoldItalic.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-Italic.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-Light.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-LightItalic.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-Medium.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-MediumItalic.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-Regular.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-SemiBold.ttf +0 -0
- package/templates/common/assets/fonts/Figtree/static/Figtree-SemiBoldItalic.ttf +0 -0
- package/templates/common/assets/fonts/index.ts +1 -0
- package/templates/common/assets/icons/index.ts +0 -0
- package/templates/common/assets/images/index.ts +0 -0
- package/templates/common/assets/index.ts +1 -0
- package/templates/common/features/welcome/screens/WelcomeScreen.tsx +8 -2
- package/templates/common/web/main.tsx +2 -0
- package/templates/common/web/styles.css +21 -0
- package/templates/expo/package.json +2 -1
- package/templates/standalone/package.json +9 -3
- package/templates/standalone/react-native.config.js +3 -0
- package/templates/standalone/scripts/android.js +574 -0
- package/templates/tsconfig.json +11 -0
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Assets
|
|
2
|
+
|
|
3
|
+
This folder contains the application's shared assets, including fonts, images, and icons.
|
|
4
|
+
|
|
5
|
+
Assets are organized by type so they can be reused across the Web and Mobile applications.
|
|
6
|
+
|
|
7
|
+
## Folder Structure
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
assets/
|
|
11
|
+
├── fonts/
|
|
12
|
+
│ ├── Figtree/
|
|
13
|
+
│ └── index.ts
|
|
14
|
+
├── images/
|
|
15
|
+
├── icons/
|
|
16
|
+
└── index.ts
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Fonts
|
|
20
|
+
|
|
21
|
+
Place font files inside `fonts/`, organized by font family.
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
fonts/
|
|
27
|
+
└── Figtree/
|
|
28
|
+
├── Figtree-VariableFont_wght.ttf
|
|
29
|
+
├── Figtree-Italic-VariableFont_wght.ttf
|
|
30
|
+
├── static/
|
|
31
|
+
└── index.ts
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Font references can be exported through the font family's `index.ts` and accessed from the assets entry point.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Figtree } from "./assets";
|
|
38
|
+
|
|
39
|
+
const regularFont = Figtree.variable.normal;
|
|
40
|
+
const italicFont = Figtree.variable.italic;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Web and Mobile may require different font-loading and registration procedures. The same font files can be shared where supported.
|
|
44
|
+
|
|
45
|
+
## Images
|
|
46
|
+
|
|
47
|
+
Place application images inside `images/`. Organize them into subfolders when needed.
|
|
48
|
+
|
|
49
|
+
## Icons
|
|
50
|
+
|
|
51
|
+
Place application icon assets inside `icons/`. Organize them by category or purpose when needed.
|
|
52
|
+
|
|
53
|
+
## Guidelines
|
|
54
|
+
|
|
55
|
+
- Keep shared assets inside this folder.
|
|
56
|
+
- Organize assets by type and font family.
|
|
57
|
+
- Use descriptive filenames.
|
|
58
|
+
- Avoid duplicating the same asset unnecessarily.
|
|
59
|
+
- Keep font license files alongside their font files.
|
|
60
|
+
- Use platform-specific asset loading where required.
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2022 The Figtree Project Authors (https://github.com/erikdkennedy/figtree)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
https://openfontlicense.org
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Figtree Variable Font
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
This download contains Figtree as both variable fonts and static fonts.
|
|
5
|
+
|
|
6
|
+
Figtree is a variable font with this axis:
|
|
7
|
+
wght
|
|
8
|
+
|
|
9
|
+
This means all the styles are contained in these files:
|
|
10
|
+
Figtree/Figtree-VariableFont_wght.ttf
|
|
11
|
+
Figtree/Figtree-Italic-VariableFont_wght.ttf
|
|
12
|
+
|
|
13
|
+
If your app fully supports variable fonts, you can now pick intermediate styles
|
|
14
|
+
that aren’t available as static fonts. Not all apps support variable fonts, and
|
|
15
|
+
in those cases you can use the static font files for Figtree:
|
|
16
|
+
Figtree/static/Figtree-Light.ttf
|
|
17
|
+
Figtree/static/Figtree-Regular.ttf
|
|
18
|
+
Figtree/static/Figtree-Medium.ttf
|
|
19
|
+
Figtree/static/Figtree-SemiBold.ttf
|
|
20
|
+
Figtree/static/Figtree-Bold.ttf
|
|
21
|
+
Figtree/static/Figtree-ExtraBold.ttf
|
|
22
|
+
Figtree/static/Figtree-Black.ttf
|
|
23
|
+
Figtree/static/Figtree-LightItalic.ttf
|
|
24
|
+
Figtree/static/Figtree-Italic.ttf
|
|
25
|
+
Figtree/static/Figtree-MediumItalic.ttf
|
|
26
|
+
Figtree/static/Figtree-SemiBoldItalic.ttf
|
|
27
|
+
Figtree/static/Figtree-BoldItalic.ttf
|
|
28
|
+
Figtree/static/Figtree-ExtraBoldItalic.ttf
|
|
29
|
+
Figtree/static/Figtree-BlackItalic.ttf
|
|
30
|
+
|
|
31
|
+
Get started
|
|
32
|
+
-----------
|
|
33
|
+
|
|
34
|
+
1. Install the font files you want to use
|
|
35
|
+
|
|
36
|
+
2. Use your app's font picker to view the font family and all the
|
|
37
|
+
available styles
|
|
38
|
+
|
|
39
|
+
Learn more about variable fonts
|
|
40
|
+
-------------------------------
|
|
41
|
+
|
|
42
|
+
https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
|
|
43
|
+
https://variablefonts.typenetwork.com
|
|
44
|
+
https://medium.com/variable-fonts
|
|
45
|
+
|
|
46
|
+
In desktop apps
|
|
47
|
+
|
|
48
|
+
https://theblog.adobe.com/can-variable-fonts-illustrator-cc
|
|
49
|
+
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts
|
|
50
|
+
|
|
51
|
+
Online
|
|
52
|
+
|
|
53
|
+
https://developers.google.com/fonts/docs/getting_started
|
|
54
|
+
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
|
|
55
|
+
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts
|
|
56
|
+
|
|
57
|
+
Installing fonts
|
|
58
|
+
|
|
59
|
+
MacOS: https://support.apple.com/en-us/HT201749
|
|
60
|
+
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
|
|
61
|
+
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows
|
|
62
|
+
|
|
63
|
+
Android Apps
|
|
64
|
+
|
|
65
|
+
https://developers.google.com/fonts/docs/android
|
|
66
|
+
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
|
|
67
|
+
|
|
68
|
+
License
|
|
69
|
+
-------
|
|
70
|
+
Please read the full license text (OFL.txt) to understand the permissions,
|
|
71
|
+
restrictions and requirements for usage, redistribution, and modification.
|
|
72
|
+
|
|
73
|
+
You can use them in your products & projects – print or digital,
|
|
74
|
+
commercial or otherwise.
|
|
75
|
+
|
|
76
|
+
This isn't legal advice, please consider consulting a lawyer and see the full
|
|
77
|
+
license for all details.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const Figtree = {
|
|
2
|
+
family: "Figtree",
|
|
3
|
+
|
|
4
|
+
variable: {
|
|
5
|
+
normal: "./assets/fonts/Figtree/Figtree-VariableFont_wght.ttf",
|
|
6
|
+
italic: "./assets/fonts/Figtree/Figtree-Italic-VariableFont_wght.ttf",
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
static: {
|
|
10
|
+
light: "./assets/fonts/Figtree/static/Figtree-Light.ttf",
|
|
11
|
+
regular: "./assets/fonts/Figtree/static/Figtree-Regular.ttf",
|
|
12
|
+
medium: "./assets/fonts/Figtree/static/Figtree-Medium.ttf",
|
|
13
|
+
semibold: "./assets/fonts/Figtree/static/Figtree-SemiBold.ttf",
|
|
14
|
+
bold: "./assets/fonts/Figtree/static/Figtree-Bold.ttf",
|
|
15
|
+
extrabold: "./assets/fonts/Figtree/static/Figtree-ExtraBold.ttf",
|
|
16
|
+
black: "./assets/fonts/Figtree/static/Figtree-Black.ttf",
|
|
17
|
+
|
|
18
|
+
lightItalic: "./assets/fonts/Figtree/static/Figtree-LightItalic.ttf",
|
|
19
|
+
italic: "./assets/fonts/Figtree/static/Figtree-Italic.ttf",
|
|
20
|
+
mediumItalic: "./assets/fonts/Figtree/static/Figtree-MediumItalic.ttf",
|
|
21
|
+
semiboldItalic: "./assets/fonts/Figtree/static/Figtree-SemiBoldItalic.ttf",
|
|
22
|
+
boldItalic: "./assets/fonts/Figtree/static/Figtree-BoldItalic.ttf",
|
|
23
|
+
extraboldItalic:
|
|
24
|
+
"./assets/fonts/Figtree/static/Figtree-ExtraBoldItalic.ttf",
|
|
25
|
+
blackItalic: "./assets/fonts/Figtree/static/Figtree-BlackItalic.ttf",
|
|
26
|
+
},
|
|
27
|
+
} as const;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Figtree";
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fonts";
|
|
@@ -4,7 +4,9 @@ export function WelcomeScreen() {
|
|
|
4
4
|
return (
|
|
5
5
|
<View style={styles.container}>
|
|
6
6
|
<Text style={styles.title}>Welcome to Beever!</Text>
|
|
7
|
-
<Text
|
|
7
|
+
<Text style={styles.subtitle}>
|
|
8
|
+
Your cross-platform project starts here.
|
|
9
|
+
</Text>
|
|
8
10
|
</View>
|
|
9
11
|
);
|
|
10
12
|
}
|
|
@@ -17,8 +19,12 @@ const styles = StyleSheet.create({
|
|
|
17
19
|
padding: 24,
|
|
18
20
|
},
|
|
19
21
|
title: {
|
|
22
|
+
fontFamily: "Figtree-Bold",
|
|
20
23
|
fontSize: 24,
|
|
21
|
-
fontWeight: "bold",
|
|
22
24
|
marginBottom: 8,
|
|
23
25
|
},
|
|
26
|
+
subtitle: {
|
|
27
|
+
fontFamily: "Figtree-Regular",
|
|
28
|
+
fontSize: 16,
|
|
29
|
+
},
|
|
24
30
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: "Figtree";
|
|
3
|
+
src: url("../assets/fonts/Figtree/Figtree-VariableFont_wght.ttf")
|
|
4
|
+
format("truetype");
|
|
5
|
+
font-weight: 300 900;
|
|
6
|
+
font-style: normal;
|
|
7
|
+
font-display: swap;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@font-face {
|
|
11
|
+
font-family: "Figtree";
|
|
12
|
+
src: url("../assets/fonts/Figtree/Figtree-Italic-VariableFont_wght.ttf")
|
|
13
|
+
format("truetype");
|
|
14
|
+
font-weight: 300 900;
|
|
15
|
+
font-style: italic;
|
|
16
|
+
font-display: swap;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
body {
|
|
20
|
+
font-family: "Figtree", sans-serif;
|
|
21
|
+
}
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
+
"postinstall": "react-native-asset",
|
|
6
7
|
"web": "vite web --config web/vite.config.ts",
|
|
7
8
|
"build:web": "vite build web --config web/vite.config.ts",
|
|
8
|
-
"android": "
|
|
9
|
+
"install:android:emulator": "node scripts/android.js install:emulator",
|
|
10
|
+
"install:android:device": "node scripts/android.js install:device",
|
|
11
|
+
"android:emulator": "node scripts/android.js emulator",
|
|
12
|
+
"android:device": "node scripts/android.js device",
|
|
9
13
|
"ios": "react-native run-ios",
|
|
10
14
|
"lint": "eslint .",
|
|
11
15
|
"start": "react-native start",
|
|
@@ -13,7 +17,7 @@
|
|
|
13
17
|
},
|
|
14
18
|
"dependencies": {
|
|
15
19
|
"@beever/web": "0.1.0",
|
|
16
|
-
"@beever/mobile": "0.1.
|
|
20
|
+
"@beever/mobile": "0.1.1",
|
|
17
21
|
"react": "19.3.0",
|
|
18
22
|
"react-dom": "19.3.0",
|
|
19
23
|
"react-native": "0.88.1"
|
|
@@ -39,9 +43,11 @@
|
|
|
39
43
|
"prettier": "2.8.8",
|
|
40
44
|
"react-test-renderer": "19.3.0",
|
|
41
45
|
"typescript": "^6.0.3",
|
|
42
|
-
"vite": "^7.3.8"
|
|
46
|
+
"vite": "^7.3.8",
|
|
47
|
+
"react-native-asset": "^2.3.0"
|
|
43
48
|
},
|
|
44
49
|
"engines": {
|
|
45
50
|
"node": ">= 22.11.0"
|
|
46
51
|
}
|
|
47
52
|
}
|
|
53
|
+
|
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const os = require('node:os');
|
|
4
|
+
const http = require('node:http');
|
|
5
|
+
const net = require('node:net');
|
|
6
|
+
const readline = require('node:readline/promises');
|
|
7
|
+
const { spawn, spawnSync } = require('node:child_process');
|
|
8
|
+
|
|
9
|
+
const projectRoot = path.resolve(__dirname, '..');
|
|
10
|
+
const androidDirectory = path.join(projectRoot, 'android');
|
|
11
|
+
|
|
12
|
+
const applicationId = '{{androidPackage}}';
|
|
13
|
+
const metroPort = 8081;
|
|
14
|
+
|
|
15
|
+
// --------------------------------------------------
|
|
16
|
+
// ADB
|
|
17
|
+
// --------------------------------------------------
|
|
18
|
+
|
|
19
|
+
function getAdbPath() {
|
|
20
|
+
const sdkPaths = [
|
|
21
|
+
process.env.ANDROID_HOME,
|
|
22
|
+
process.env.ANDROID_SDK_ROOT,
|
|
23
|
+
process.env.LOCALAPPDATA
|
|
24
|
+
? path.join(process.env.LOCALAPPDATA, 'Android', 'Sdk')
|
|
25
|
+
: null,
|
|
26
|
+
].filter(Boolean);
|
|
27
|
+
|
|
28
|
+
for (const sdkPath of sdkPaths) {
|
|
29
|
+
const adbPath = path.join(
|
|
30
|
+
sdkPath,
|
|
31
|
+
'platform-tools',
|
|
32
|
+
process.platform === 'win32' ? 'adb.exe' : 'adb',
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (fs.existsSync(adbPath)) {
|
|
36
|
+
return adbPath;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
throw new Error(
|
|
41
|
+
'Android SDK not found. Install Android SDK or configure ANDROID_HOME.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function runAdb(args) {
|
|
46
|
+
const result = spawnSync(getAdbPath(), args, {
|
|
47
|
+
encoding: 'utf8',
|
|
48
|
+
windowsHide: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (result.error) {
|
|
52
|
+
throw result.error;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (result.status !== 0) {
|
|
56
|
+
throw new Error(result.stderr || result.stdout || 'ADB command failed.');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return result.stdout.trim();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --------------------------------------------------
|
|
63
|
+
// Android device detection
|
|
64
|
+
// --------------------------------------------------
|
|
65
|
+
|
|
66
|
+
function getAndroidDevices() {
|
|
67
|
+
let adbPath;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
adbPath = getAdbPath();
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const result = spawnSync(adbPath, ['devices', '-l'], {
|
|
76
|
+
encoding: 'utf8',
|
|
77
|
+
windowsHide: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (result.error) {
|
|
81
|
+
throw result.error;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (result.status !== 0) {
|
|
85
|
+
throw new Error(result.stderr || 'Unable to detect Android devices.');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const devices = result.stdout
|
|
89
|
+
.split(/\r?\n/)
|
|
90
|
+
.slice(1)
|
|
91
|
+
.filter(line => line.trim())
|
|
92
|
+
.map(line => {
|
|
93
|
+
const parts = line.trim().split(/\s+/);
|
|
94
|
+
const serial = parts[0];
|
|
95
|
+
const state = parts[1];
|
|
96
|
+
const model = parts.find(part => part.startsWith('model:'))?.slice(6);
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
serial,
|
|
100
|
+
state,
|
|
101
|
+
model: model || serial,
|
|
102
|
+
type: serial.startsWith('emulator-') ? 'emulator' : 'device',
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Remove duplicate connections to the same physical device.
|
|
107
|
+
// Prefer the direct IP connection over the mDNS connection.
|
|
108
|
+
const uniqueDevices = new Map();
|
|
109
|
+
|
|
110
|
+
for (const device of devices) {
|
|
111
|
+
if (!device.model || device.state !== 'device') {
|
|
112
|
+
uniqueDevices.set(device.serial, device);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const existing = uniqueDevices.get(device.model);
|
|
117
|
+
|
|
118
|
+
if (!existing) {
|
|
119
|
+
uniqueDevices.set(device.model, device);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const existingIsDirect = /^\d{1,3}(?:\.\d{1,3}){3}:\d+$/.test(
|
|
124
|
+
existing.serial,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const currentIsDirect = /^\d{1,3}(?:\.\d{1,3}){3}:\d+$/.test(device.serial);
|
|
128
|
+
|
|
129
|
+
if (currentIsDirect && !existingIsDirect) {
|
|
130
|
+
uniqueDevices.set(device.model, device);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return [...uniqueDevices.values()];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function selectAndroidTarget(type, allowMissing = false) {
|
|
138
|
+
const devices = getAndroidDevices();
|
|
139
|
+
|
|
140
|
+
if (devices === null) {
|
|
141
|
+
if (allowMissing) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
throw new Error(
|
|
146
|
+
'Android SDK or ADB not found. Install Android SDK and configure ANDROID_HOME.',
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const targets = devices.filter(
|
|
151
|
+
device => device.type === type && device.state === 'device',
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
if (targets.length === 0) {
|
|
155
|
+
const unavailable = devices.filter(device => device.type === type);
|
|
156
|
+
|
|
157
|
+
if (unavailable.length > 0) {
|
|
158
|
+
console.error(`\nFound an Android ${type}, but it isn't ready:`);
|
|
159
|
+
|
|
160
|
+
unavailable.forEach(device => {
|
|
161
|
+
console.error(` ${device.serial}: ${device.state}`);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
throw new Error(
|
|
165
|
+
'Check the device connection and USB debugging authorization.',
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (allowMissing) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
throw new Error(
|
|
174
|
+
type === 'emulator'
|
|
175
|
+
? 'No Android emulator found. Start an emulator first.'
|
|
176
|
+
: 'No Android phone found. Connect your phone using USB or wireless debugging.',
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (targets.length === 1) {
|
|
181
|
+
return targets[0];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
console.log(`\nMultiple Android ${type}s found:\n`);
|
|
185
|
+
|
|
186
|
+
targets.forEach((device, index) => {
|
|
187
|
+
console.log(` ${index + 1}. ${device.model} (${device.serial})`);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const rl = readline.createInterface({
|
|
191
|
+
input: process.stdin,
|
|
192
|
+
output: process.stdout,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
const answer = await rl.question('\nSelect a device: ');
|
|
197
|
+
const index = Number(answer) - 1;
|
|
198
|
+
|
|
199
|
+
if (!Number.isInteger(index) || !targets[index]) {
|
|
200
|
+
throw new Error('Invalid device selection.');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return targets[index];
|
|
204
|
+
} finally {
|
|
205
|
+
rl.close();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// --------------------------------------------------
|
|
210
|
+
// Android APK building and installation
|
|
211
|
+
// --------------------------------------------------
|
|
212
|
+
|
|
213
|
+
function buildAndroidApk() {
|
|
214
|
+
const gradleWrapper = path.join(
|
|
215
|
+
androidDirectory,
|
|
216
|
+
process.platform === 'win32' ? 'gradlew.bat' : 'gradlew',
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
if (!fs.existsSync(gradleWrapper)) {
|
|
220
|
+
throw new Error('Android Gradle wrapper not found.');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
console.log('\nBuilding Android debug APK...\n');
|
|
224
|
+
|
|
225
|
+
const result =
|
|
226
|
+
process.platform === 'win32'
|
|
227
|
+
? spawnSync('cmd.exe', ['/d', '/c', 'gradlew.bat app:assembleDebug'], {
|
|
228
|
+
cwd: androidDirectory,
|
|
229
|
+
stdio: 'inherit',
|
|
230
|
+
windowsHide: true,
|
|
231
|
+
})
|
|
232
|
+
: spawnSync(gradleWrapper, ['app:assembleDebug'], {
|
|
233
|
+
cwd: androidDirectory,
|
|
234
|
+
stdio: 'inherit',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (result.error) {
|
|
238
|
+
throw result.error;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (result.status !== 0) {
|
|
242
|
+
throw new Error('Android APK build failed.');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return path.join(
|
|
246
|
+
androidDirectory,
|
|
247
|
+
'app',
|
|
248
|
+
'build',
|
|
249
|
+
'outputs',
|
|
250
|
+
'apk',
|
|
251
|
+
'debug',
|
|
252
|
+
'app-debug.apk',
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function installApk(device, apkPath) {
|
|
257
|
+
console.log(`\nInstalling APK on ${device.model}...\n`);
|
|
258
|
+
|
|
259
|
+
const output = runAdb(['-s', device.serial, 'install', '-r', apkPath]);
|
|
260
|
+
|
|
261
|
+
console.log(output);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// --------------------------------------------------
|
|
265
|
+
// App launching
|
|
266
|
+
// --------------------------------------------------
|
|
267
|
+
|
|
268
|
+
function launchApp(device) {
|
|
269
|
+
console.log(`\nLaunching Beever app on ${device.model}...\n`);
|
|
270
|
+
|
|
271
|
+
const output = runAdb([
|
|
272
|
+
'-s',
|
|
273
|
+
device.serial,
|
|
274
|
+
'shell',
|
|
275
|
+
'monkey',
|
|
276
|
+
'-p',
|
|
277
|
+
applicationId,
|
|
278
|
+
'-c',
|
|
279
|
+
'android.intent.category.LAUNCHER',
|
|
280
|
+
'1',
|
|
281
|
+
]);
|
|
282
|
+
|
|
283
|
+
console.log(output);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// --------------------------------------------------
|
|
287
|
+
// Metro detection
|
|
288
|
+
// --------------------------------------------------
|
|
289
|
+
|
|
290
|
+
function isMetroRunning(port) {
|
|
291
|
+
return new Promise(resolve => {
|
|
292
|
+
const request = http.get(`http://127.0.0.1:${port}/status`, response => {
|
|
293
|
+
let body = '';
|
|
294
|
+
|
|
295
|
+
response.on('data', chunk => {
|
|
296
|
+
body += chunk;
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
response.on('end', () => {
|
|
300
|
+
resolve(
|
|
301
|
+
response.statusCode === 200 &&
|
|
302
|
+
body.includes('packager-status:running'),
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
request.setTimeout(2000, () => {
|
|
308
|
+
request.destroy();
|
|
309
|
+
resolve(false);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
request.on('error', () => resolve(false));
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function isPortAvailable(port) {
|
|
317
|
+
return new Promise(resolve => {
|
|
318
|
+
const server = net.createServer();
|
|
319
|
+
|
|
320
|
+
server.once('error', () => resolve(false));
|
|
321
|
+
|
|
322
|
+
server.once('listening', () => {
|
|
323
|
+
server.close(() => resolve(true));
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
server.listen(port, '127.0.0.1');
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async function waitForMetro(child) {
|
|
331
|
+
const startedAt = Date.now();
|
|
332
|
+
|
|
333
|
+
while (Date.now() - startedAt < 60000) {
|
|
334
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
335
|
+
throw new Error('Metro stopped before it became ready.');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (await isMetroRunning(metroPort)) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
throw new Error('Metro did not start within 60 seconds.');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async function startMetro() {
|
|
349
|
+
if (await isMetroRunning(metroPort)) {
|
|
350
|
+
console.log(`\nMetro is already running on port ${metroPort}.`);
|
|
351
|
+
console.log('Reusing the existing Metro server.');
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (!(await isPortAvailable(metroPort))) {
|
|
356
|
+
throw new Error(
|
|
357
|
+
`Port ${metroPort} is occupied by another application. ` +
|
|
358
|
+
'Close that application before starting Beever.',
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const cliPath = path.join(
|
|
363
|
+
projectRoot,
|
|
364
|
+
'node_modules',
|
|
365
|
+
'react-native',
|
|
366
|
+
'cli.js',
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
if (!fs.existsSync(cliPath)) {
|
|
370
|
+
throw new Error('React Native CLI not found. Run npm install first.');
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
console.log(`\nStarting Metro on port ${metroPort}...\n`);
|
|
374
|
+
|
|
375
|
+
const child = spawn(
|
|
376
|
+
process.execPath,
|
|
377
|
+
[cliPath, 'start', '--port', String(metroPort), '--host', '0.0.0.0'],
|
|
378
|
+
{
|
|
379
|
+
cwd: projectRoot,
|
|
380
|
+
stdio: 'inherit',
|
|
381
|
+
windowsHide: true,
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
let spawnError = null;
|
|
386
|
+
|
|
387
|
+
child.on('error', error => {
|
|
388
|
+
spawnError = error;
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
try {
|
|
392
|
+
await waitForMetro(child);
|
|
393
|
+
} catch (error) {
|
|
394
|
+
if (spawnError) {
|
|
395
|
+
throw spawnError;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
console.log('\nMetro is ready!');
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// --------------------------------------------------
|
|
405
|
+
// Local network detection
|
|
406
|
+
// --------------------------------------------------
|
|
407
|
+
|
|
408
|
+
function getLocalIPv4Addresses() {
|
|
409
|
+
const interfaces = os.networkInterfaces();
|
|
410
|
+
const addresses = [];
|
|
411
|
+
|
|
412
|
+
for (const entries of Object.values(interfaces)) {
|
|
413
|
+
for (const entry of entries || []) {
|
|
414
|
+
const isIPv4 = entry.family === 'IPv4' || entry.family === 4;
|
|
415
|
+
|
|
416
|
+
if (!isIPv4 || entry.internal) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const address = entry.address;
|
|
421
|
+
|
|
422
|
+
const isPrivate =
|
|
423
|
+
/^10\./.test(address) ||
|
|
424
|
+
/^192\.168\./.test(address) ||
|
|
425
|
+
/^172\.(1[6-9]|2\d|3[01])\./.test(address);
|
|
426
|
+
|
|
427
|
+
if (isPrivate && !addresses.includes(address)) {
|
|
428
|
+
addresses.push(address);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return addresses;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function showWifiInstructions() {
|
|
437
|
+
const addresses = getLocalIPv4Addresses();
|
|
438
|
+
|
|
439
|
+
console.log('\n--------------------------------------------');
|
|
440
|
+
console.log(' BEEVER WI-FI DEVELOPMENT');
|
|
441
|
+
console.log('--------------------------------------------');
|
|
442
|
+
|
|
443
|
+
console.log('\nNo ADB-connected phone was detected.');
|
|
444
|
+
console.log('Metro is running and ready for a Wi-Fi connection.');
|
|
445
|
+
|
|
446
|
+
if (addresses.length === 0) {
|
|
447
|
+
console.log('\nCould not automatically detect your local IPv4 address.');
|
|
448
|
+
console.log('Run ipconfig on Windows to find your Wi-Fi IPv4 address.');
|
|
449
|
+
} else {
|
|
450
|
+
console.log('\nAvailable Metro addresses:\n');
|
|
451
|
+
|
|
452
|
+
addresses.forEach(address => {
|
|
453
|
+
console.log(` ${address}:${metroPort}`);
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
console.log('\nOn your Android phone:');
|
|
458
|
+
console.log(' 1. Connect to the same Wi-Fi network as your computer.');
|
|
459
|
+
console.log(' 2. Open your installed Beever app.');
|
|
460
|
+
console.log(' 3. Open the React Native Developer Menu.');
|
|
461
|
+
console.log(' 4. Select Settings.');
|
|
462
|
+
console.log(' 5. Open Debug server host & port for device.');
|
|
463
|
+
console.log(' 6. Enter your computer IP address and port.');
|
|
464
|
+
console.log(` Example: 192.168.1.52:${metroPort}`);
|
|
465
|
+
console.log(' 7. Return to the app and reload it.');
|
|
466
|
+
|
|
467
|
+
console.log('\nKeep this terminal open while developing.');
|
|
468
|
+
console.log(
|
|
469
|
+
'Make sure your firewall allows Node.js on your private network.',
|
|
470
|
+
);
|
|
471
|
+
console.log('--------------------------------------------\n');
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// --------------------------------------------------
|
|
475
|
+
// Device-to-Metro connection
|
|
476
|
+
// --------------------------------------------------
|
|
477
|
+
|
|
478
|
+
function connectDeviceToMetro(device) {
|
|
479
|
+
console.log(`\nConnecting ${device.model} to Metro...\n`);
|
|
480
|
+
|
|
481
|
+
runAdb([
|
|
482
|
+
'-s',
|
|
483
|
+
device.serial,
|
|
484
|
+
'reverse',
|
|
485
|
+
`tcp:${metroPort}`,
|
|
486
|
+
`tcp:${metroPort}`,
|
|
487
|
+
]);
|
|
488
|
+
|
|
489
|
+
console.log(`Device connected to Metro on port ${metroPort}.`);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// --------------------------------------------------
|
|
493
|
+
// Install commands
|
|
494
|
+
// --------------------------------------------------
|
|
495
|
+
|
|
496
|
+
async function installEmulator() {
|
|
497
|
+
const device = await selectAndroidTarget('emulator');
|
|
498
|
+
const apkPath = buildAndroidApk();
|
|
499
|
+
|
|
500
|
+
installApk(device, apkPath);
|
|
501
|
+
|
|
502
|
+
console.log('\nBeever app successfully installed on the emulator!');
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async function installDevice() {
|
|
506
|
+
const device = await selectAndroidTarget('device');
|
|
507
|
+
const apkPath = buildAndroidApk();
|
|
508
|
+
|
|
509
|
+
installApk(device, apkPath);
|
|
510
|
+
|
|
511
|
+
console.log('\nBeever app successfully installed on the phone!');
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// --------------------------------------------------
|
|
515
|
+
// Development commands
|
|
516
|
+
// --------------------------------------------------
|
|
517
|
+
|
|
518
|
+
async function developEmulator() {
|
|
519
|
+
const device = await selectAndroidTarget('emulator');
|
|
520
|
+
|
|
521
|
+
await startMetro();
|
|
522
|
+
|
|
523
|
+
connectDeviceToMetro(device);
|
|
524
|
+
launchApp(device);
|
|
525
|
+
|
|
526
|
+
console.log('\nBeever is running on the emulator!');
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
async function developDevice() {
|
|
530
|
+
const device = await selectAndroidTarget('device', true);
|
|
531
|
+
|
|
532
|
+
await startMetro();
|
|
533
|
+
|
|
534
|
+
if (!device) {
|
|
535
|
+
showWifiInstructions();
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
connectDeviceToMetro(device);
|
|
540
|
+
launchApp(device);
|
|
541
|
+
|
|
542
|
+
console.log('\nBeever is running on the phone!');
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// --------------------------------------------------
|
|
546
|
+
// Command registration
|
|
547
|
+
// --------------------------------------------------
|
|
548
|
+
|
|
549
|
+
const commands = {
|
|
550
|
+
'install:emulator': installEmulator,
|
|
551
|
+
'install:device': installDevice,
|
|
552
|
+
emulator: developEmulator,
|
|
553
|
+
device: developDevice,
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
const command = process.argv[2];
|
|
557
|
+
|
|
558
|
+
if (!command || !commands[command]) {
|
|
559
|
+
console.error(
|
|
560
|
+
'\nUnknown Android command.\n\n' +
|
|
561
|
+
'Available commands:\n' +
|
|
562
|
+
' install:emulator\n' +
|
|
563
|
+
' install:device\n' +
|
|
564
|
+
' emulator\n' +
|
|
565
|
+
' device\n',
|
|
566
|
+
);
|
|
567
|
+
|
|
568
|
+
process.exit(1);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
commands[command]().catch(error => {
|
|
572
|
+
console.error(`\nAndroid error: ${error.message}`);
|
|
573
|
+
process.exit(1);
|
|
574
|
+
});
|