beever-create 0.1.1 → 0.1.4
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/dist/index.js +214 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/templates/expo/app.config.js +1 -0
- package/templates/expo/mobile/app.config.js +11 -0
- package/templates/{package.json → expo/package.json} +3 -2
- package/templates/standalone/.eslintrc.js +4 -0
- package/templates/standalone/.prettierrc.js +5 -0
- package/templates/standalone/.watchmanconfig +1 -0
- package/templates/standalone/Gemfile +17 -0
- package/templates/standalone/android/app/build.gradle +119 -0
- package/templates/standalone/android/app/debug.keystore +0 -0
- package/templates/standalone/android/app/proguard-rules.pro +10 -0
- package/templates/standalone/android/app/src/main/AndroidManifest.xml +27 -0
- package/templates/standalone/android/app/src/main/java/com/beevernativetemplatetest/MainActivity.kt +22 -0
- package/templates/standalone/android/app/src/main/java/com/beevernativetemplatetest/MainApplication.kt +27 -0
- package/templates/standalone/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/templates/standalone/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/templates/standalone/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/templates/standalone/android/app/src/main/res/values/strings.xml +3 -0
- package/templates/standalone/android/app/src/main/res/values/styles.xml +9 -0
- package/templates/standalone/android/build.gradle +21 -0
- package/templates/standalone/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/standalone/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/templates/standalone/android/gradle.properties +49 -0
- package/templates/standalone/android/gradlew +248 -0
- package/templates/standalone/android/gradlew.bat +98 -0
- package/templates/standalone/android/settings.gradle +6 -0
- package/templates/standalone/app.json +4 -0
- package/templates/standalone/babel.config.js +3 -0
- package/templates/standalone/index.js +5 -0
- package/templates/standalone/ios/.xcode.env +11 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/AppDelegate.swift +11 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/Images.xcassets/Contents.json +6 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/Info.plist +78 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/LaunchScreen.storyboard +47 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/PrivacyInfo.xcprivacy +37 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest/SceneDelegate.swift +56 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest.xcodeproj/project.pbxproj +479 -0
- package/templates/standalone/ios/BeeverNativeTemplateTest.xcodeproj/xcshareddata/xcschemes/BeeverNativeTemplateTest.xcscheme +76 -0
- package/templates/standalone/ios/Podfile +34 -0
- package/templates/standalone/jest.config.js +3 -0
- package/templates/standalone/metro.config.js +11 -0
- package/templates/standalone/package.json +47 -0
- package/templates/standalone/tsconfig.json.template +5 -0
- package/templates/mobile/app.json +0 -9
- /package/templates/{features → common/features}/welcome/index.ts +0 -0
- /package/templates/{features → common/features}/welcome/pages/WelcomePage.tsx +0 -0
- /package/templates/{features → common/features}/welcome/screens/WelcomeScreen.tsx +0 -0
- /package/templates/{mobile → common/mobile}/App.tsx +0 -0
- /package/templates/{shared → common/shared}/index.ts +0 -0
- /package/templates/{web → common/web}/index.html +0 -0
- /package/templates/{web → common/web}/main.tsx +0 -0
- /package/templates/{web → common/web}/vite.config.ts +0 -0
- /package/templates/{README.md → expo/README.md} +0 -0
- /package/templates/{mobile → expo/mobile}/index.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -5,16 +5,18 @@ import fs from "fs";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { spawnSync } from "child_process";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
|
+
import { createInterface } from "readline/promises";
|
|
9
|
+
import { stdin, stdout } from "process";
|
|
8
10
|
var projectName = process.argv[2];
|
|
9
11
|
if (!projectName) {
|
|
10
12
|
console.log("Please provide a project name.");
|
|
11
13
|
console.log("Usage: npx beever-create <project-name>");
|
|
12
14
|
process.exit(1);
|
|
13
15
|
}
|
|
14
|
-
var validProjectName = /^[a-zA-Z0-9_-]
|
|
16
|
+
var validProjectName = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(projectName);
|
|
15
17
|
if (!validProjectName) {
|
|
16
18
|
console.error(
|
|
17
|
-
"Invalid project name.
|
|
19
|
+
"Invalid project name. Start with a letter or number and use only letters, numbers, hyphens, and underscores."
|
|
18
20
|
);
|
|
19
21
|
process.exit(1);
|
|
20
22
|
}
|
|
@@ -25,64 +27,231 @@ if (fs.existsSync(projectPath)) {
|
|
|
25
27
|
}
|
|
26
28
|
var currentDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
27
29
|
var templatesPath = path.resolve(currentDirectory, "../templates");
|
|
30
|
+
var commonTemplatePath = path.join(templatesPath, "common");
|
|
31
|
+
var expoTemplatePath = path.join(templatesPath, "expo");
|
|
32
|
+
var standaloneTemplatePath = path.join(templatesPath, "standalone");
|
|
28
33
|
var packageName = projectName.toLowerCase().replace(/_/g, "-");
|
|
29
|
-
|
|
34
|
+
var displayName = projectName.replace(/[-_]+/g, " ").trim();
|
|
35
|
+
var appNameParts = projectName.split(/[-_]+/).filter(Boolean);
|
|
36
|
+
var appName = appNameParts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
37
|
+
if (!appName || /^[0-9]/.test(appName)) {
|
|
38
|
+
appName = `App${appName}`;
|
|
39
|
+
}
|
|
40
|
+
var nativePackageName = projectName.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
41
|
+
var safeNativePackageName = /^[a-z]/.test(nativePackageName) ? nativePackageName : `app${nativePackageName}`;
|
|
42
|
+
var androidPackage = `com.beever.${safeNativePackageName}`;
|
|
43
|
+
var iosBundleIdentifier = `com.beever.${safeNativePackageName}`;
|
|
44
|
+
var textFileExtensions = /* @__PURE__ */ new Set([
|
|
45
|
+
".json",
|
|
46
|
+
".js",
|
|
47
|
+
".jsx",
|
|
48
|
+
".ts",
|
|
49
|
+
".tsx",
|
|
50
|
+
".gradle",
|
|
51
|
+
".properties",
|
|
52
|
+
".kt",
|
|
53
|
+
".swift",
|
|
54
|
+
".plist",
|
|
55
|
+
".storyboard",
|
|
56
|
+
".xcprivacy",
|
|
57
|
+
".pbxproj",
|
|
58
|
+
".xcscheme",
|
|
59
|
+
".xml",
|
|
60
|
+
".md",
|
|
61
|
+
".txt",
|
|
62
|
+
".html",
|
|
63
|
+
".css",
|
|
64
|
+
".scss",
|
|
65
|
+
".yml",
|
|
66
|
+
".yaml",
|
|
67
|
+
".toml"
|
|
68
|
+
]);
|
|
69
|
+
var placeholderValues = {
|
|
70
|
+
"{{projectName}}": packageName,
|
|
71
|
+
"{{packageName}}": packageName,
|
|
72
|
+
"{{displayName}}": displayName,
|
|
73
|
+
"{{appName}}": appName,
|
|
74
|
+
"{{androidPackage}}": androidPackage,
|
|
75
|
+
"{{iosBundleIdentifier}}": iosBundleIdentifier
|
|
76
|
+
};
|
|
77
|
+
function replaceTemplatePlaceholders(directory) {
|
|
30
78
|
const entries = fs.readdirSync(directory, {
|
|
31
79
|
withFileTypes: true
|
|
32
80
|
});
|
|
33
81
|
for (const entry of entries) {
|
|
34
82
|
const entryPath = path.join(directory, entry.name);
|
|
35
83
|
if (entry.isDirectory()) {
|
|
36
|
-
|
|
84
|
+
replaceTemplatePlaceholders(entryPath);
|
|
37
85
|
continue;
|
|
38
86
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"utf8"
|
|
45
|
-
);
|
|
87
|
+
const extension = path.extname(entry.name).toLowerCase();
|
|
88
|
+
const isPodfile = entry.name === "Podfile";
|
|
89
|
+
const isTextFile = isPodfile || textFileExtensions.has(extension);
|
|
90
|
+
if (!isTextFile) {
|
|
91
|
+
continue;
|
|
46
92
|
}
|
|
93
|
+
let content = fs.readFileSync(entryPath, "utf8");
|
|
94
|
+
for (const [placeholder, value] of Object.entries(placeholderValues)) {
|
|
95
|
+
content = content.split(placeholder).join(value);
|
|
96
|
+
}
|
|
97
|
+
fs.writeFileSync(entryPath, content, "utf8");
|
|
47
98
|
}
|
|
48
99
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
100
|
+
function renameStandaloneNativeDirectories() {
|
|
101
|
+
const androidPackageDirectory = path.join(
|
|
102
|
+
projectPath,
|
|
103
|
+
"android",
|
|
104
|
+
"app",
|
|
105
|
+
"src",
|
|
106
|
+
"main",
|
|
107
|
+
"java",
|
|
108
|
+
"com",
|
|
109
|
+
"beevernativetemplatetest"
|
|
110
|
+
);
|
|
111
|
+
const androidPackageParent = path.dirname(androidPackageDirectory);
|
|
112
|
+
const androidPackageTarget = path.join(
|
|
113
|
+
androidPackageParent,
|
|
114
|
+
"beever",
|
|
115
|
+
safeNativePackageName
|
|
116
|
+
);
|
|
117
|
+
if (fs.existsSync(androidPackageDirectory)) {
|
|
118
|
+
fs.mkdirSync(path.dirname(androidPackageTarget), {
|
|
119
|
+
recursive: true
|
|
120
|
+
});
|
|
121
|
+
fs.renameSync(androidPackageDirectory, androidPackageTarget);
|
|
122
|
+
}
|
|
123
|
+
const iosDirectory = path.join(projectPath, "ios");
|
|
124
|
+
const oldIosAppDirectory = path.join(
|
|
125
|
+
iosDirectory,
|
|
126
|
+
"BeeverNativeTemplateTest"
|
|
127
|
+
);
|
|
128
|
+
const newIosAppDirectory = path.join(iosDirectory, appName);
|
|
129
|
+
if (fs.existsSync(oldIosAppDirectory)) {
|
|
130
|
+
fs.renameSync(oldIosAppDirectory, newIosAppDirectory);
|
|
52
131
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
132
|
+
const oldXcodeProjectDirectory = path.join(
|
|
133
|
+
iosDirectory,
|
|
134
|
+
"BeeverNativeTemplateTest.xcodeproj"
|
|
135
|
+
);
|
|
136
|
+
const newXcodeProjectDirectory = path.join(
|
|
137
|
+
iosDirectory,
|
|
138
|
+
`${appName}.xcodeproj`
|
|
139
|
+
);
|
|
140
|
+
if (fs.existsSync(oldXcodeProjectDirectory)) {
|
|
141
|
+
fs.renameSync(oldXcodeProjectDirectory, newXcodeProjectDirectory);
|
|
142
|
+
}
|
|
143
|
+
const oldSchemeFile = path.join(
|
|
144
|
+
newXcodeProjectDirectory,
|
|
145
|
+
"xcshareddata",
|
|
146
|
+
"xcschemes",
|
|
147
|
+
"BeeverNativeTemplateTest.xcscheme"
|
|
148
|
+
);
|
|
149
|
+
const newSchemeFile = path.join(
|
|
150
|
+
newXcodeProjectDirectory,
|
|
151
|
+
"xcshareddata",
|
|
152
|
+
"xcschemes",
|
|
153
|
+
`${appName}.xcscheme`
|
|
154
|
+
);
|
|
155
|
+
if (fs.existsSync(oldSchemeFile)) {
|
|
156
|
+
fs.renameSync(oldSchemeFile, newSchemeFile);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function selectMobileProjectType() {
|
|
160
|
+
const rl = createInterface({
|
|
161
|
+
input: stdin,
|
|
162
|
+
output: stdout
|
|
56
163
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
164
|
+
try {
|
|
165
|
+
console.log("\nWhich mobile setup would you like?\n");
|
|
166
|
+
console.log(" 1. React Native Standalone");
|
|
167
|
+
console.log(" 2. React Native with Expo\n");
|
|
168
|
+
const answer = (await rl.question("Choose an option (1 or 2): ")).trim();
|
|
169
|
+
if (answer === "1") {
|
|
170
|
+
return "standalone";
|
|
171
|
+
}
|
|
172
|
+
if (answer === "2") {
|
|
173
|
+
return "expo";
|
|
174
|
+
}
|
|
175
|
+
throw new Error("Invalid selection. Please choose 1 or 2.");
|
|
176
|
+
} finally {
|
|
177
|
+
rl.close();
|
|
67
178
|
}
|
|
68
|
-
console.error(error);
|
|
69
|
-
process.exit(1);
|
|
70
179
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
180
|
+
async function main() {
|
|
181
|
+
let mobileProjectType;
|
|
182
|
+
try {
|
|
183
|
+
mobileProjectType = await selectMobileProjectType();
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error(error instanceof Error ? error.message : error);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
const selectedTemplatePath = mobileProjectType === "standalone" ? standaloneTemplatePath : expoTemplatePath;
|
|
189
|
+
try {
|
|
190
|
+
if (!fs.existsSync(commonTemplatePath)) {
|
|
191
|
+
throw new Error("Common project template not found.");
|
|
192
|
+
}
|
|
193
|
+
if (!fs.existsSync(selectedTemplatePath)) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
`The ${mobileProjectType} project template was not found.`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
fs.mkdirSync(projectPath);
|
|
199
|
+
fs.cpSync(commonTemplatePath, projectPath, {
|
|
200
|
+
recursive: true
|
|
201
|
+
});
|
|
202
|
+
fs.cpSync(selectedTemplatePath, projectPath, {
|
|
203
|
+
recursive: true
|
|
204
|
+
});
|
|
205
|
+
if (mobileProjectType === "standalone") {
|
|
206
|
+
const templateTsconfigPath = path.join(
|
|
207
|
+
projectPath,
|
|
208
|
+
"tsconfig.json.template"
|
|
209
|
+
);
|
|
210
|
+
const projectTsconfigPath = path.join(projectPath, "tsconfig.json");
|
|
211
|
+
if (fs.existsSync(templateTsconfigPath)) {
|
|
212
|
+
fs.renameSync(templateTsconfigPath, projectTsconfigPath);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
replaceTemplatePlaceholders(projectPath);
|
|
216
|
+
if (mobileProjectType === "standalone") {
|
|
217
|
+
renameStandaloneNativeDirectories();
|
|
218
|
+
}
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error("\nFailed to create Beever project.");
|
|
221
|
+
if (fs.existsSync(projectPath)) {
|
|
222
|
+
fs.rmSync(projectPath, {
|
|
223
|
+
recursive: true,
|
|
224
|
+
force: true
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
console.error(error);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
console.log("\nInstalling project dependencies...\n");
|
|
231
|
+
const installOptions = {
|
|
232
|
+
cwd: projectPath,
|
|
233
|
+
stdio: "inherit"
|
|
234
|
+
};
|
|
235
|
+
const installResult = process.platform === "win32" ? spawnSync(
|
|
236
|
+
process.env.ComSpec || "cmd.exe",
|
|
237
|
+
["/d", "/s", "/c", "npm install"],
|
|
238
|
+
installOptions
|
|
239
|
+
) : spawnSync("npm", ["install"], installOptions);
|
|
240
|
+
if (installResult.error || installResult.status !== 0) {
|
|
241
|
+
console.error("\nDependency installation failed.");
|
|
242
|
+
console.error(`Your project was created at: ${projectPath}`);
|
|
243
|
+
console.error("You can retry by running 'npm install' inside the project.");
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
console.log("\nBeever project created successfully!\n");
|
|
247
|
+
console.log("Your Beever project is ready for:");
|
|
248
|
+
console.log(" - Web");
|
|
249
|
+
if (mobileProjectType === "standalone") {
|
|
250
|
+
console.log(" - React Native Standalone");
|
|
251
|
+
} else {
|
|
252
|
+
console.log(" - React Native with Expo");
|
|
253
|
+
}
|
|
254
|
+
console.log("\nDependencies installed successfully!");
|
|
82
255
|
}
|
|
83
|
-
|
|
84
|
-
console.log("\nYour Beever project is ready!");
|
|
85
|
-
console.log("\nNext steps:");
|
|
86
|
-
console.log(` cd ${projectName}`);
|
|
87
|
-
console.log(" npm run web");
|
|
256
|
+
await main();
|
|
88
257
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\r\nimport path from \"node:path\";\r\nimport { spawnSync } from \"node:child_process\";\r\nimport { fileURLToPath } from \"node:url\";\r\n\r\nconst projectName = process.argv[2];\r\n\r\nif (!projectName) {\r\n console.log(\"Please provide a project name.\");\r\n console.log(\"Usage: npx beever-create <project-name>\");\r\n process.exit(1);\r\n}\r\n\r\nconst validProjectName = /^[a-zA-Z0-9_-]+$/.test(projectName);\r\n\r\nif (!validProjectName) {\r\n console.error(\r\n \"Invalid project name. Use only letters, numbers, hyphens, and underscores.\",\r\n );\r\n process.exit(1);\r\n}\r\n\r\nconst projectPath = path.resolve(process.cwd(), projectName);\r\n\r\nif (fs.existsSync(projectPath)) {\r\n console.error(`A folder named \"${projectName}\" already exists.`);\r\n process.exit(1);\r\n}\r\n\r\nconst currentDirectory = path.dirname(fileURLToPath(import.meta.url));\r\nconst templatesPath = path.resolve(currentDirectory, \"../templates\");\r\n\r\nconst packageName = projectName.toLowerCase().replace(/_/g, \"-\");\r\n\r\nfunction replaceProjectName(directory: string) {\r\n const entries = fs.readdirSync(directory, {\r\n withFileTypes: true,\r\n });\r\n\r\n for (const entry of entries) {\r\n const entryPath = path.join(directory, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n replaceProjectName(entryPath);\r\n continue;\r\n }\r\n\r\n const content = fs.readFileSync(entryPath, \"utf8\");\r\n\r\n if (content.includes(\"{{projectName}}\")) {\r\n fs.writeFileSync(\r\n entryPath,\r\n content.split(\"{{projectName}}\").join(packageName),\r\n \"utf8\",\r\n );\r\n }\r\n }\r\n}\r\n\r\ntry {\r\n if (!fs.existsSync(templatesPath)) {\r\n throw new Error(\"Project templates directory not found.\");\r\n }\r\n\r\n fs.mkdirSync(projectPath);\r\n\r\n fs.cpSync(templatesPath, projectPath, {\r\n recursive: true,\r\n });\r\n\r\n replaceProjectName(projectPath);\r\n\r\n console.log(\"\\nBeever project created successfully!\");\r\n console.log(`Project location: ${projectPath}`);\r\n} catch (error) {\r\n console.error(\"\\nFailed to create Beever project.\");\r\n\r\n if (fs.existsSync(projectPath)) {\r\n fs.rmSync(projectPath, {\r\n recursive: true,\r\n force: true,\r\n });\r\n }\r\n\r\n console.error(error);\r\n process.exit(1);\r\n}\r\n\r\n// Automatically install project dependencies.\r\nconsole.log(\"\\nInstalling project dependencies...\\n\");\r\n\r\nconst installResult = spawnSync(\"npm\", [\"install\"], {\r\n cwd: projectPath,\r\n stdio: \"inherit\",\r\n shell: process.platform === \"win32\",\r\n});\r\n\r\nif (installResult.error || installResult.status !== 0) {\r\n console.error(\"\\nDependency installation failed.\");\r\n console.error(`Your project was created at: ${projectPath}`);\r\n console.error(\"You can retry by running 'npm install' inside the project.\");\r\n process.exit(1);\r\n}\r\n\r\nconsole.log(\"\\nDependencies installed successfully!\");\r\nconsole.log(\"\\nYour Beever project is ready!\");\r\n\r\nconsole.log(\"\\nNext steps:\");\r\nconsole.log(` cd ${projectName}`);\r\nconsole.log(\" npm run web\");\r\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,IAAM,cAAc,QAAQ,KAAK,CAAC;AAElC,IAAI,CAAC,aAAa;AAChB,UAAQ,IAAI,gCAAgC;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BAAqB,WAAW,EAAE;AAChD,SAAS,OAAO;AACd,UAAQ,MAAM,oCAAoC;AAElD,MAAI,GAAG,WAAW,WAAW,GAAG;AAC9B,OAAG,OAAO,aAAa;AAAA,MACrB,WAAW;AAAA,MACX,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,CAAC;AAChB;AAGA,QAAQ,IAAI,wCAAwC;AAEpD,IAAM,gBAAgB,UAAU,OAAO,CAAC,SAAS,GAAG;AAAA,EAClD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,QAAQ,aAAa;AAC9B,CAAC;AAED,IAAI,cAAc,SAAS,cAAc,WAAW,GAAG;AACrD,UAAQ,MAAM,mCAAmC;AACjD,UAAQ,MAAM,gCAAgC,WAAW,EAAE;AAC3D,UAAQ,MAAM,4DAA4D;AAC1E,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,IAAI,wCAAwC;AACpD,QAAQ,IAAI,iCAAiC;AAE7C,QAAQ,IAAI,eAAe;AAC3B,QAAQ,IAAI,QAAQ,WAAW,EAAE;AACjC,QAAQ,IAAI,eAAe;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\r\nimport path from \"node:path\";\r\nimport { spawnSync } from \"node:child_process\";\r\nimport { fileURLToPath } from \"node:url\";\r\nimport { createInterface } from \"node:readline/promises\";\r\nimport { stdin, stdout } from \"node:process\";\r\n\r\ntype MobileProjectType = \"standalone\" | \"expo\";\r\n\r\nconst projectName = process.argv[2];\r\n\r\nif (!projectName) {\r\n console.log(\"Please provide a project name.\");\r\n console.log(\"Usage: npx beever-create <project-name>\");\r\n process.exit(1);\r\n}\r\n\r\n// Validate the project name before creating anything.\r\nconst validProjectName = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(projectName);\r\n\r\nif (!validProjectName) {\r\n console.error(\r\n \"Invalid project name. Start with a letter or number and use only letters, numbers, hyphens, and underscores.\",\r\n );\r\n process.exit(1);\r\n}\r\n\r\nconst projectPath = path.resolve(process.cwd(), projectName);\r\n\r\nif (fs.existsSync(projectPath)) {\r\n console.error(`A folder named \"${projectName}\" already exists.`);\r\n process.exit(1);\r\n}\r\n\r\n// Resolve template directories.\r\nconst currentDirectory = path.dirname(fileURLToPath(import.meta.url));\r\nconst templatesPath = path.resolve(currentDirectory, \"../templates\");\r\n\r\nconst commonTemplatePath = path.join(templatesPath, \"common\");\r\nconst expoTemplatePath = path.join(templatesPath, \"expo\");\r\nconst standaloneTemplatePath = path.join(templatesPath, \"standalone\");\r\n\r\n// Generate project identifiers.\r\nconst packageName = projectName.toLowerCase().replace(/_/g, \"-\");\r\n\r\nconst displayName = projectName.replace(/[-_]+/g, \" \").trim();\r\n\r\nconst appNameParts = projectName.split(/[-_]+/).filter(Boolean);\r\n\r\nlet appName = appNameParts\r\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\r\n .join(\"\");\r\n\r\nif (!appName || /^[0-9]/.test(appName)) {\r\n appName = `App${appName}`;\r\n}\r\n\r\nconst nativePackageName = projectName.toLowerCase().replace(/[^a-z0-9]/g, \"\");\r\n\r\nconst safeNativePackageName = /^[a-z]/.test(nativePackageName)\r\n ? nativePackageName\r\n : `app${nativePackageName}`;\r\n\r\nconst androidPackage = `com.beever.${safeNativePackageName}`;\r\nconst iosBundleIdentifier = `com.beever.${safeNativePackageName}`;\r\n\r\n// Only these files are processed as text.\r\n// Binary assets are deliberately excluded.\r\nconst textFileExtensions = new Set([\r\n \".json\",\r\n \".js\",\r\n \".jsx\",\r\n \".ts\",\r\n \".tsx\",\r\n \".gradle\",\r\n \".properties\",\r\n \".kt\",\r\n \".swift\",\r\n \".plist\",\r\n \".storyboard\",\r\n \".xcprivacy\",\r\n \".pbxproj\",\r\n \".xcscheme\",\r\n \".xml\",\r\n \".md\",\r\n \".txt\",\r\n \".html\",\r\n \".css\",\r\n \".scss\",\r\n \".yml\",\r\n \".yaml\",\r\n \".toml\",\r\n]);\r\n\r\nconst placeholderValues: Record<string, string> = {\r\n \"{{projectName}}\": packageName,\r\n \"{{packageName}}\": packageName,\r\n \"{{displayName}}\": displayName,\r\n \"{{appName}}\": appName,\r\n \"{{androidPackage}}\": androidPackage,\r\n \"{{iosBundleIdentifier}}\": iosBundleIdentifier,\r\n};\r\n\r\nfunction replaceTemplatePlaceholders(directory: string) {\r\n const entries = fs.readdirSync(directory, {\r\n withFileTypes: true,\r\n });\r\n\r\n for (const entry of entries) {\r\n const entryPath = path.join(directory, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n replaceTemplatePlaceholders(entryPath);\r\n continue;\r\n }\r\n\r\n const extension = path.extname(entry.name).toLowerCase();\r\n\r\n const isPodfile = entry.name === \"Podfile\";\r\n const isTextFile = isPodfile || textFileExtensions.has(extension);\r\n\r\n if (!isTextFile) {\r\n continue;\r\n }\r\n\r\n let content = fs.readFileSync(entryPath, \"utf8\");\r\n\r\n for (const [placeholder, value] of Object.entries(placeholderValues)) {\r\n content = content.split(placeholder).join(value);\r\n }\r\n\r\n fs.writeFileSync(entryPath, content, \"utf8\");\r\n }\r\n}\r\n\r\nfunction renameStandaloneNativeDirectories() {\r\n const androidPackageDirectory = path.join(\r\n projectPath,\r\n \"android\",\r\n \"app\",\r\n \"src\",\r\n \"main\",\r\n \"java\",\r\n \"com\",\r\n \"beevernativetemplatetest\",\r\n );\r\n\r\n const androidPackageParent = path.dirname(androidPackageDirectory);\r\n\r\n const androidPackageTarget = path.join(\r\n androidPackageParent,\r\n \"beever\",\r\n safeNativePackageName,\r\n );\r\n\r\n if (fs.existsSync(androidPackageDirectory)) {\r\n fs.mkdirSync(path.dirname(androidPackageTarget), {\r\n recursive: true,\r\n });\r\n\r\n fs.renameSync(androidPackageDirectory, androidPackageTarget);\r\n }\r\n\r\n const iosDirectory = path.join(projectPath, \"ios\");\r\n\r\n const oldIosAppDirectory = path.join(\r\n iosDirectory,\r\n \"BeeverNativeTemplateTest\",\r\n );\r\n\r\n const newIosAppDirectory = path.join(iosDirectory, appName);\r\n\r\n if (fs.existsSync(oldIosAppDirectory)) {\r\n fs.renameSync(oldIosAppDirectory, newIosAppDirectory);\r\n }\r\n\r\n const oldXcodeProjectDirectory = path.join(\r\n iosDirectory,\r\n \"BeeverNativeTemplateTest.xcodeproj\",\r\n );\r\n\r\n const newXcodeProjectDirectory = path.join(\r\n iosDirectory,\r\n `${appName}.xcodeproj`,\r\n );\r\n\r\n if (fs.existsSync(oldXcodeProjectDirectory)) {\r\n fs.renameSync(oldXcodeProjectDirectory, newXcodeProjectDirectory);\r\n }\r\n\r\n const oldSchemeFile = path.join(\r\n newXcodeProjectDirectory,\r\n \"xcshareddata\",\r\n \"xcschemes\",\r\n \"BeeverNativeTemplateTest.xcscheme\",\r\n );\r\n\r\n const newSchemeFile = path.join(\r\n newXcodeProjectDirectory,\r\n \"xcshareddata\",\r\n \"xcschemes\",\r\n `${appName}.xcscheme`,\r\n );\r\n\r\n if (fs.existsSync(oldSchemeFile)) {\r\n fs.renameSync(oldSchemeFile, newSchemeFile);\r\n }\r\n}\r\n\r\nasync function selectMobileProjectType(): Promise<MobileProjectType> {\r\n const rl = createInterface({\r\n input: stdin,\r\n output: stdout,\r\n });\r\n\r\n try {\r\n console.log(\"\\nWhich mobile setup would you like?\\n\");\r\n console.log(\" 1. React Native Standalone\");\r\n console.log(\" 2. React Native with Expo\\n\");\r\n\r\n const answer = (await rl.question(\"Choose an option (1 or 2): \")).trim();\r\n\r\n if (answer === \"1\") {\r\n return \"standalone\";\r\n }\r\n\r\n if (answer === \"2\") {\r\n return \"expo\";\r\n }\r\n\r\n throw new Error(\"Invalid selection. Please choose 1 or 2.\");\r\n } finally {\r\n rl.close();\r\n }\r\n}\r\n\r\nasync function main() {\r\n let mobileProjectType: MobileProjectType;\r\n\r\n try {\r\n mobileProjectType = await selectMobileProjectType();\r\n } catch (error) {\r\n console.error(error instanceof Error ? error.message : error);\r\n process.exit(1);\r\n }\r\n\r\n const selectedTemplatePath =\r\n mobileProjectType === \"standalone\"\r\n ? standaloneTemplatePath\r\n : expoTemplatePath;\r\n\r\n try {\r\n // Verify the required template directories.\r\n if (!fs.existsSync(commonTemplatePath)) {\r\n throw new Error(\"Common project template not found.\");\r\n }\r\n\r\n if (!fs.existsSync(selectedTemplatePath)) {\r\n throw new Error(\r\n `The ${mobileProjectType} project template was not found.`,\r\n );\r\n }\r\n\r\n // Create the project directory.\r\n fs.mkdirSync(projectPath);\r\n\r\n // Copy shared application code first.\r\n fs.cpSync(commonTemplatePath, projectPath, {\r\n recursive: true,\r\n });\r\n\r\n // Overlay the selected mobile project template.\r\n fs.cpSync(selectedTemplatePath, projectPath, {\r\n recursive: true,\r\n });\r\n\r\n // Restore the TypeScript configuration filename for Standalone projects.\r\n if (mobileProjectType === \"standalone\") {\r\n const templateTsconfigPath = path.join(\r\n projectPath,\r\n \"tsconfig.json.template\",\r\n );\r\n\r\n const projectTsconfigPath = path.join(projectPath, \"tsconfig.json\");\r\n\r\n if (fs.existsSync(templateTsconfigPath)) {\r\n fs.renameSync(templateTsconfigPath, projectTsconfigPath);\r\n }\r\n }\r\n\r\n // Replace template placeholders in text files.\r\n replaceTemplatePlaceholders(projectPath);\r\n\r\n // Rename native project directories for Standalone.\r\n if (mobileProjectType === \"standalone\") {\r\n renameStandaloneNativeDirectories();\r\n }\r\n } catch (error) {\r\n console.error(\"\\nFailed to create Beever project.\");\r\n\r\n if (fs.existsSync(projectPath)) {\r\n fs.rmSync(projectPath, {\r\n recursive: true,\r\n force: true,\r\n });\r\n }\r\n\r\n console.error(error);\r\n process.exit(1);\r\n }\r\n\r\n // Automatically install project dependencies.\r\n console.log(\"\\nInstalling project dependencies...\\n\");\r\n\r\n const installOptions = {\r\n cwd: projectPath,\r\n stdio: \"inherit\" as const,\r\n };\r\n\r\n const installResult =\r\n process.platform === \"win32\"\r\n ? spawnSync(\r\n process.env.ComSpec || \"cmd.exe\",\r\n [\"/d\", \"/s\", \"/c\", \"npm install\"],\r\n installOptions,\r\n )\r\n : spawnSync(\"npm\", [\"install\"], installOptions);\r\n\r\n if (installResult.error || installResult.status !== 0) {\r\n console.error(\"\\nDependency installation failed.\");\r\n console.error(`Your project was created at: ${projectPath}`);\r\n console.error(\"You can retry by running 'npm install' inside the project.\");\r\n process.exit(1);\r\n }\r\n\r\n // Display the appropriate success message.\r\n console.log(\"\\nBeever project created successfully!\\n\");\r\n console.log(\"Your Beever project is ready for:\");\r\n console.log(\" - Web\");\r\n\r\n if (mobileProjectType === \"standalone\") {\r\n console.log(\" - React Native Standalone\");\r\n } else {\r\n console.log(\" - React Native with Expo\");\r\n }\r\n\r\n console.log(\"\\nDependencies installed successfully!\");\r\n}\r\n\r\nawait main();\r\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,OAAO,cAAc;AAI9B,IAAM,cAAc,QAAQ,KAAK,CAAC;AAElC,IAAI,CAAC,aAAa;AAChB,UAAQ,IAAI,gCAAgC;AAC5C,UAAQ,IAAI,yCAAyC;AACrD,UAAQ,KAAK,CAAC;AAChB;AAGA,IAAM,mBAAmB,8BAA8B,KAAK,WAAW;AAEvE,IAAI,CAAC,kBAAkB;AACrB,UAAQ;AAAA,IACN;AAAA,EACF;AACA,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,cAAc,KAAK,QAAQ,QAAQ,IAAI,GAAG,WAAW;AAE3D,IAAI,GAAG,WAAW,WAAW,GAAG;AAC9B,UAAQ,MAAM,mBAAmB,WAAW,mBAAmB;AAC/D,UAAQ,KAAK,CAAC;AAChB;AAGA,IAAM,mBAAmB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AACpE,IAAM,gBAAgB,KAAK,QAAQ,kBAAkB,cAAc;AAEnE,IAAM,qBAAqB,KAAK,KAAK,eAAe,QAAQ;AAC5D,IAAM,mBAAmB,KAAK,KAAK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AQ,IAAI,SAAS;AAErB,MAAI,sBAAsB,cAAc;AACtC,YAAQ,IAAI,6BAA6B;AAAA,EAC3C,OAAO;AACL,YAAQ,IAAI,4BAA4B;AAAA,EAC1C;AAEA,UAAQ,IAAI,wCAAwC;AACtD;AAEA,MAAM,KAAK;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beever-create",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "CLI tool for creating Beever projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "tsup"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@react-native/typescript-config": "0.88.1",
|
|
18
19
|
"@types/node": "^20.19.0",
|
|
19
20
|
"tsup": "^9.0.0",
|
|
20
21
|
"typescript": "^6.0.3"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./mobile/app.config.js").expo;
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"web": "vite web --config web/vite.config.ts",
|
|
8
8
|
"build:web": "vite build web --config web/vite.config.ts",
|
|
9
|
-
"mobile": "expo start --
|
|
9
|
+
"mobile": "expo start --dev-client"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@beever/web": "0.1.0",
|
|
13
13
|
"@beever/mobile": "0.1.0",
|
|
14
14
|
"expo": "~58.0.26",
|
|
15
|
+
"expo-dev-client": "~58.0.21",
|
|
15
16
|
"react": "19.3.0",
|
|
16
17
|
"react-dom": "19.3.0",
|
|
17
18
|
"react-native": "0.88.1"
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/react": "^19.3.0",
|
|
21
22
|
"@types/react-dom": "^19.3.0",
|
|
22
|
-
"typescript": "
|
|
23
|
+
"typescript": "~6.0.3",
|
|
23
24
|
"vite": "^7.3.8"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
|
4
|
+
ruby ">= 2.6.10"
|
|
5
|
+
|
|
6
|
+
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
|
|
7
|
+
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
|
|
8
|
+
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
|
|
9
|
+
gem 'xcodeproj', '< 1.26.0'
|
|
10
|
+
gem 'concurrent-ruby', '< 1.3.4'
|
|
11
|
+
|
|
12
|
+
# Ruby 3.4.0 has removed some libraries from the standard library.
|
|
13
|
+
gem 'bigdecimal'
|
|
14
|
+
gem 'logger'
|
|
15
|
+
gem 'benchmark'
|
|
16
|
+
gem 'mutex_m'
|
|
17
|
+
gem 'nkf'
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
apply plugin: "com.android.application"
|
|
2
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
3
|
+
apply plugin: "com.facebook.react"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is the configuration block to customize your React Native Android app.
|
|
7
|
+
* By default you don't need to apply any configuration, just uncomment the lines you need.
|
|
8
|
+
*/
|
|
9
|
+
react {
|
|
10
|
+
/* Folders */
|
|
11
|
+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
|
|
12
|
+
// root = file("../../")
|
|
13
|
+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
|
|
14
|
+
// reactNativeDir = file("../../node_modules/react-native")
|
|
15
|
+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
|
|
16
|
+
// codegenDir = file("../../node_modules/@react-native/codegen")
|
|
17
|
+
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
|
|
18
|
+
// cliFile = file("../../node_modules/react-native/cli.js")
|
|
19
|
+
|
|
20
|
+
/* Variants */
|
|
21
|
+
// The list of variants to that are debuggable. For those we're going to
|
|
22
|
+
// skip the bundling of the JS bundle and the assets. Default is "debug", "debugOptimized".
|
|
23
|
+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
|
|
24
|
+
// debuggableVariants = ["liteDebug", "liteDebugOptimized", "prodDebug", "prodDebugOptimized"]
|
|
25
|
+
|
|
26
|
+
/* Bundling */
|
|
27
|
+
// A list containing the node command and its flags. Default is just 'node'.
|
|
28
|
+
// nodeExecutableAndArgs = ["node"]
|
|
29
|
+
//
|
|
30
|
+
// The command to run when bundling. By default is 'bundle'
|
|
31
|
+
// bundleCommand = "ram-bundle"
|
|
32
|
+
//
|
|
33
|
+
// The path to the CLI configuration file. Default is empty.
|
|
34
|
+
// bundleConfig = file(../rn-cli.config.js)
|
|
35
|
+
//
|
|
36
|
+
// The name of the generated asset file containing your JS bundle
|
|
37
|
+
// bundleAssetName = "MyApplication.android.bundle"
|
|
38
|
+
//
|
|
39
|
+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
|
|
40
|
+
// entryFile = file("../js/MyApplication.android.js")
|
|
41
|
+
//
|
|
42
|
+
// A list of extra flags to pass to the 'bundle' commands.
|
|
43
|
+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
|
|
44
|
+
// extraPackagerArgs = []
|
|
45
|
+
|
|
46
|
+
/* Hermes Commands */
|
|
47
|
+
// The hermes compiler command to run. By default it is 'hermesc'
|
|
48
|
+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
|
|
49
|
+
//
|
|
50
|
+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
|
51
|
+
// hermesFlags = ["-O", "-output-source-map"]
|
|
52
|
+
|
|
53
|
+
/* Autolinking */
|
|
54
|
+
autolinkLibrariesWithApp()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
|
|
59
|
+
*/
|
|
60
|
+
def enableProguardInReleaseBuilds = false
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The preferred build flavor of JavaScriptCore (JSC)
|
|
64
|
+
*
|
|
65
|
+
* For example, to use the international variant, you can use:
|
|
66
|
+
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
|
|
67
|
+
*
|
|
68
|
+
* The international variant includes ICU i18n library and necessary data
|
|
69
|
+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
|
|
70
|
+
* give correct results when using with locales other than en-US. Note that
|
|
71
|
+
* this variant is about 6MiB larger per architecture than default.
|
|
72
|
+
*/
|
|
73
|
+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
|
|
74
|
+
|
|
75
|
+
android {
|
|
76
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
77
|
+
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
78
|
+
compileSdk rootProject.ext.compileSdkVersion
|
|
79
|
+
|
|
80
|
+
namespace "{{androidPackage}}"
|
|
81
|
+
defaultConfig {
|
|
82
|
+
applicationId "{{androidPackage}}"
|
|
83
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
84
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
85
|
+
versionCode 1
|
|
86
|
+
versionName "1.0"
|
|
87
|
+
}
|
|
88
|
+
signingConfigs {
|
|
89
|
+
debug {
|
|
90
|
+
storeFile file('debug.keystore')
|
|
91
|
+
storePassword 'android'
|
|
92
|
+
keyAlias 'androiddebugkey'
|
|
93
|
+
keyPassword 'android'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
buildTypes {
|
|
97
|
+
debug {
|
|
98
|
+
signingConfig signingConfigs.debug
|
|
99
|
+
}
|
|
100
|
+
release {
|
|
101
|
+
// Caution! In production, you need to generate your own keystore file.
|
|
102
|
+
// see https://reactnative.dev/docs/signed-apk-android.
|
|
103
|
+
signingConfig signingConfigs.debug
|
|
104
|
+
minifyEnabled enableProguardInReleaseBuilds
|
|
105
|
+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
dependencies {
|
|
111
|
+
// The version of react-native is set by the React Native Gradle Plugin
|
|
112
|
+
implementation("com.facebook.react:react-android")
|
|
113
|
+
|
|
114
|
+
if (hermesEnabled.toBoolean()) {
|
|
115
|
+
implementation("com.facebook.react:hermes-android")
|
|
116
|
+
} else {
|
|
117
|
+
implementation jscFlavor
|
|
118
|
+
}
|
|
119
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
# By default, the flags in this file are appended to flags specified
|
|
3
|
+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
|
|
4
|
+
# You can edit the include path and order by changing the proguardFiles
|
|
5
|
+
# directive in build.gradle.
|
|
6
|
+
#
|
|
7
|
+
# For more details, see
|
|
8
|
+
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
9
|
+
|
|
10
|
+
# Add any project specific keep options here:
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
|
|
3
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
4
|
+
|
|
5
|
+
<application
|
|
6
|
+
android:name=".MainApplication"
|
|
7
|
+
android:label="@string/app_name"
|
|
8
|
+
android:icon="@mipmap/ic_launcher"
|
|
9
|
+
android:roundIcon="@mipmap/ic_launcher_round"
|
|
10
|
+
android:allowBackup="false"
|
|
11
|
+
android:theme="@style/AppTheme"
|
|
12
|
+
android:usesCleartextTraffic="${usesCleartextTraffic}"
|
|
13
|
+
android:supportsRtl="true">
|
|
14
|
+
<activity
|
|
15
|
+
android:name=".MainActivity"
|
|
16
|
+
android:label="@string/app_name"
|
|
17
|
+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
|
|
18
|
+
android:launchMode="singleTask"
|
|
19
|
+
android:windowSoftInputMode="adjustResize"
|
|
20
|
+
android:exported="true">
|
|
21
|
+
<intent-filter>
|
|
22
|
+
<action android:name="android.intent.action.MAIN" />
|
|
23
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
|
24
|
+
</intent-filter>
|
|
25
|
+
</activity>
|
|
26
|
+
</application>
|
|
27
|
+
</manifest>
|
package/templates/standalone/android/app/src/main/java/com/beevernativetemplatetest/MainActivity.kt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package {{androidPackage}}
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactActivity
|
|
4
|
+
import com.facebook.react.ReactActivityDelegate
|
|
5
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
6
|
+
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
|
7
|
+
|
|
8
|
+
class MainActivity : ReactActivity() {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
12
|
+
* rendering of the component.
|
|
13
|
+
*/
|
|
14
|
+
override fun getMainComponentName(): String = "{{appName}}"
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
|
|
18
|
+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
|
19
|
+
*/
|
|
20
|
+
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
|
21
|
+
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package {{androidPackage}}
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import com.facebook.react.PackageList
|
|
5
|
+
import com.facebook.react.ReactApplication
|
|
6
|
+
import com.facebook.react.ReactHost
|
|
7
|
+
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
|
|
8
|
+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
9
|
+
|
|
10
|
+
class MainApplication : Application(), ReactApplication {
|
|
11
|
+
|
|
12
|
+
override val reactHost: ReactHost by lazy {
|
|
13
|
+
getDefaultReactHost(
|
|
14
|
+
context = applicationContext,
|
|
15
|
+
packageList =
|
|
16
|
+
PackageList(this).packages.apply {
|
|
17
|
+
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
18
|
+
// add(MyReactNativePackage())
|
|
19
|
+
},
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun onCreate() {
|
|
24
|
+
super.onCreate()
|
|
25
|
+
loadReactNative(this)
|
|
26
|
+
}
|
|
27
|
+
}
|