@tmhs/mobile-mcp 0.6.0 → 0.9.0
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 +23 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/addMap.d.ts +3 -0
- package/dist/tools/addMap.d.ts.map +1 -0
- package/dist/tools/addMap.js +223 -0
- package/dist/tools/addMap.js.map +1 -0
- package/dist/tools/analyzeBundle.d.ts +3 -0
- package/dist/tools/analyzeBundle.d.ts.map +1 -0
- package/dist/tools/analyzeBundle.js +122 -0
- package/dist/tools/analyzeBundle.js.map +1 -0
- package/dist/tools/checkDevEnvironment.js +1 -1
- package/dist/tools/checkDevEnvironment.js.map +1 -1
- package/dist/tools/configureOTA.d.ts +3 -0
- package/dist/tools/configureOTA.d.ts.map +1 -0
- package/dist/tools/configureOTA.js +118 -0
- package/dist/tools/configureOTA.js.map +1 -0
- package/dist/tools/generateForm.d.ts +3 -0
- package/dist/tools/generateForm.d.ts.map +1 -0
- package/dist/tools/generateForm.js +337 -0
- package/dist/tools/generateForm.js.map +1 -0
- package/dist/tools/generateScreenshots.d.ts +3 -0
- package/dist/tools/generateScreenshots.d.ts.map +1 -0
- package/dist/tools/generateScreenshots.js +128 -0
- package/dist/tools/generateScreenshots.js.map +1 -0
- package/dist/tools/generateTestFile.d.ts +3 -0
- package/dist/tools/generateTestFile.d.ts.map +1 -0
- package/dist/tools/generateTestFile.js +184 -0
- package/dist/tools/generateTestFile.js.map +1 -0
- package/dist/tools/runOnDevice.d.ts.map +1 -1
- package/dist/tools/runOnDevice.js +45 -40
- package/dist/tools/runOnDevice.js.map +1 -1
- package/dist/tools/runTests.d.ts +3 -0
- package/dist/tools/runTests.d.ts.map +1 -0
- package/dist/tools/runTests.js +165 -0
- package/dist/tools/runTests.js.map +1 -0
- package/dist/tools/scaffoldProject.js +1 -1
- package/dist/tools/scaffoldProject.js.map +1 -1
- package/dist/tools/setupCI.d.ts +3 -0
- package/dist/tools/setupCI.d.ts.map +1 -0
- package/dist/tools/setupCI.js +202 -0
- package/dist/tools/setupCI.js.map +1 -0
- package/dist/tools/setupI18n.d.ts +3 -0
- package/dist/tools/setupI18n.d.ts.map +1 -0
- package/dist/tools/setupI18n.js +155 -0
- package/dist/tools/setupI18n.js.map +1 -0
- package/dist/tools/setupRealtime.d.ts +3 -0
- package/dist/tools/setupRealtime.d.ts.map +1 -0
- package/dist/tools/setupRealtime.js +311 -0
- package/dist/tools/setupRealtime.js.map +1 -0
- package/dist/tools/submitToAppStore.js +1 -1
- package/dist/tools/submitToAppStore.js.map +1 -1
- package/dist/tools/submitToPlayStore.d.ts +3 -0
- package/dist/tools/submitToPlayStore.d.ts.map +1 -0
- package/dist/tools/submitToPlayStore.js +92 -0
- package/dist/tools/submitToPlayStore.js.map +1 -0
- package/dist/tools/validateStoreMetadata.js +1 -1
- package/dist/tools/validateStoreMetadata.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { textResponse, errorResponse } from "../types.js";
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
project_path: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Absolute path to the project root. Defaults to cwd."),
|
|
10
|
+
framework: z
|
|
11
|
+
.enum(["expo", "flutter"])
|
|
12
|
+
.optional()
|
|
13
|
+
.default("expo")
|
|
14
|
+
.describe("Project framework (default: expo)."),
|
|
15
|
+
platforms: z
|
|
16
|
+
.enum(["ios", "android", "both"])
|
|
17
|
+
.optional()
|
|
18
|
+
.default("both")
|
|
19
|
+
.describe("Target platforms for CI builds (default: both)."),
|
|
20
|
+
include_tests: z
|
|
21
|
+
.boolean()
|
|
22
|
+
.optional()
|
|
23
|
+
.default(true)
|
|
24
|
+
.describe("Include a test step in the workflow (default: true)."),
|
|
25
|
+
include_eas_build: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.optional()
|
|
28
|
+
.default(false)
|
|
29
|
+
.describe("Include EAS Build step for Expo projects (default: false). Requires EXPO_TOKEN secret."),
|
|
30
|
+
};
|
|
31
|
+
function generateExpoWorkflow(platforms, includeTests, includeEas) {
|
|
32
|
+
const platformList = platforms === "both" ? "ios, android" : platforms;
|
|
33
|
+
let testStep = "";
|
|
34
|
+
if (includeTests) {
|
|
35
|
+
testStep = `
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: npx jest --ci --coverage`;
|
|
38
|
+
}
|
|
39
|
+
let easStep = "";
|
|
40
|
+
if (includeEas) {
|
|
41
|
+
const platformFlag = platforms === "both" ? "all" : platforms;
|
|
42
|
+
easStep = `
|
|
43
|
+
|
|
44
|
+
eas-build:
|
|
45
|
+
needs: lint-and-test
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
if: github.ref == 'refs/heads/main'
|
|
48
|
+
strategy:
|
|
49
|
+
matrix:
|
|
50
|
+
platform: [${platformList}]
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- uses: actions/setup-node@v4
|
|
55
|
+
with:
|
|
56
|
+
node-version: 20
|
|
57
|
+
cache: npm
|
|
58
|
+
|
|
59
|
+
- run: npm ci
|
|
60
|
+
|
|
61
|
+
- uses: expo/expo-github-action@v8
|
|
62
|
+
with:
|
|
63
|
+
eas-version: latest
|
|
64
|
+
token: \${{ secrets.EXPO_TOKEN }}
|
|
65
|
+
|
|
66
|
+
- name: Build for \${{ matrix.platform }}
|
|
67
|
+
run: eas build --platform \${{ matrix.platform }} --profile production --non-interactive`;
|
|
68
|
+
}
|
|
69
|
+
return `name: CI
|
|
70
|
+
|
|
71
|
+
on:
|
|
72
|
+
push:
|
|
73
|
+
branches: [main]
|
|
74
|
+
pull_request:
|
|
75
|
+
branches: [main]
|
|
76
|
+
|
|
77
|
+
jobs:
|
|
78
|
+
lint-and-test:
|
|
79
|
+
runs-on: ubuntu-latest
|
|
80
|
+
steps:
|
|
81
|
+
- uses: actions/checkout@v4
|
|
82
|
+
|
|
83
|
+
- uses: actions/setup-node@v4
|
|
84
|
+
with:
|
|
85
|
+
node-version: 20
|
|
86
|
+
cache: npm
|
|
87
|
+
|
|
88
|
+
- run: npm ci
|
|
89
|
+
|
|
90
|
+
- name: Type check
|
|
91
|
+
run: npx tsc --noEmit
|
|
92
|
+
|
|
93
|
+
- name: Lint
|
|
94
|
+
run: npx expo lint
|
|
95
|
+
${testStep}
|
|
96
|
+
${easStep}
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
function generateFlutterWorkflow(platforms, includeTests) {
|
|
100
|
+
let testStep = "";
|
|
101
|
+
if (includeTests) {
|
|
102
|
+
testStep = `
|
|
103
|
+
- name: Run tests
|
|
104
|
+
run: flutter test --coverage`;
|
|
105
|
+
}
|
|
106
|
+
let buildSteps = "";
|
|
107
|
+
if (platforms === "android" || platforms === "both") {
|
|
108
|
+
buildSteps += `
|
|
109
|
+
- name: Build Android APK
|
|
110
|
+
run: flutter build apk --release`;
|
|
111
|
+
}
|
|
112
|
+
if (platforms === "ios" || platforms === "both") {
|
|
113
|
+
buildSteps += `
|
|
114
|
+
|
|
115
|
+
build-ios:
|
|
116
|
+
needs: test
|
|
117
|
+
runs-on: macos-latest
|
|
118
|
+
steps:
|
|
119
|
+
- uses: actions/checkout@v4
|
|
120
|
+
|
|
121
|
+
- uses: subosito/flutter-action@v2
|
|
122
|
+
with:
|
|
123
|
+
channel: stable
|
|
124
|
+
cache: true
|
|
125
|
+
|
|
126
|
+
- run: flutter pub get
|
|
127
|
+
|
|
128
|
+
- name: Build iOS
|
|
129
|
+
run: flutter build ios --release --no-codesign`;
|
|
130
|
+
}
|
|
131
|
+
return `name: CI
|
|
132
|
+
|
|
133
|
+
on:
|
|
134
|
+
push:
|
|
135
|
+
branches: [main]
|
|
136
|
+
pull_request:
|
|
137
|
+
branches: [main]
|
|
138
|
+
|
|
139
|
+
jobs:
|
|
140
|
+
test:
|
|
141
|
+
runs-on: ubuntu-latest
|
|
142
|
+
steps:
|
|
143
|
+
- uses: actions/checkout@v4
|
|
144
|
+
|
|
145
|
+
- uses: subosito/flutter-action@v2
|
|
146
|
+
with:
|
|
147
|
+
channel: stable
|
|
148
|
+
cache: true
|
|
149
|
+
|
|
150
|
+
- run: flutter pub get
|
|
151
|
+
|
|
152
|
+
- name: Analyze
|
|
153
|
+
run: flutter analyze
|
|
154
|
+
${testStep}
|
|
155
|
+
${buildSteps}
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
export function register(server) {
|
|
159
|
+
server.tool("mobile_setupCI", "Generate a GitHub Actions CI workflow for build, test, and optional EAS Build deployment. Creates .github/workflows/ci.yml.", inputSchema, async (args) => {
|
|
160
|
+
try {
|
|
161
|
+
const root = args.project_path || process.cwd();
|
|
162
|
+
const workflowPath = join(root, ".github", "workflows", "ci.yml");
|
|
163
|
+
if (existsSync(workflowPath)) {
|
|
164
|
+
return textResponse(JSON.stringify({
|
|
165
|
+
success: false,
|
|
166
|
+
message: `Workflow already exists at ${workflowPath}. Delete or rename it before generating a new one.`,
|
|
167
|
+
existing_file: workflowPath,
|
|
168
|
+
}, null, 2));
|
|
169
|
+
}
|
|
170
|
+
const workflow = args.framework === "flutter"
|
|
171
|
+
? generateFlutterWorkflow(args.platforms, args.include_tests)
|
|
172
|
+
: generateExpoWorkflow(args.platforms, args.include_tests, args.include_eas_build);
|
|
173
|
+
mkdirSync(dirname(workflowPath), { recursive: true });
|
|
174
|
+
writeFileSync(workflowPath, workflow, "utf-8");
|
|
175
|
+
const secrets = [];
|
|
176
|
+
if (args.include_eas_build && args.framework === "expo") {
|
|
177
|
+
secrets.push("EXPO_TOKEN - EAS CLI authentication token");
|
|
178
|
+
}
|
|
179
|
+
return textResponse(JSON.stringify({
|
|
180
|
+
success: true,
|
|
181
|
+
file_created: workflowPath,
|
|
182
|
+
framework: args.framework,
|
|
183
|
+
platforms: args.platforms,
|
|
184
|
+
includes_tests: args.include_tests,
|
|
185
|
+
includes_eas_build: args.include_eas_build,
|
|
186
|
+
required_secrets: secrets.length > 0 ? secrets : undefined,
|
|
187
|
+
next_steps: [
|
|
188
|
+
"Review the generated workflow at .github/workflows/ci.yml",
|
|
189
|
+
"Commit and push to trigger the first run",
|
|
190
|
+
...(secrets.length > 0
|
|
191
|
+
? ["Add required secrets in GitHub repo Settings > Secrets and variables > Actions"]
|
|
192
|
+
: []),
|
|
193
|
+
"Consider adding branch protection rules to require CI to pass",
|
|
194
|
+
],
|
|
195
|
+
}, null, 2));
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
return errorResponse(err);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=setupCI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupCI.js","sourceRoot":"","sources":["../../src/tools/setupCI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,GAAG;IAClB,YAAY,EAAE,CAAC;SACZ,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,qDAAqD,CAAC;IAClE,SAAS,EAAE,CAAC;SACT,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;SACzB,QAAQ,EAAE;SACV,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,oCAAoC,CAAC;IACjD,SAAS,EAAE,CAAC;SACT,IAAI,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,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/C,MAAM,OAAO,GAAa,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;gBACxD,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;YAC5D,CAAC;YAED,OAAO,YAAY,CACjB,IAAI,CAAC,SAAS,CACZ;gBACE,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,YAAY;gBAC1B,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,cAAc,EAAE,IAAI,CAAC,aAAa;gBAClC,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;gBAC1C,gBAAgB,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBAC1D,UAAU,EAAE;oBACV,2DAA2D;oBAC3D,0CAA0C;oBAC1C,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;wBACpB,CAAC,CAAC,CAAC,gFAAgF,CAAC;wBACpF,CAAC,CAAC,EAAE,CAAC;oBACP,+DAA+D;iBAChE;aACF,EACD,IAAI,EACJ,CAAC,CACF,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupI18n.d.ts","sourceRoot":"","sources":["../../src/tools/setupI18n.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2FzE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA8FhD"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { textResponse, errorResponse } from "../types.js";
|
|
5
|
+
const inputSchema = {
|
|
6
|
+
project_path: z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Absolute path to the project root. Defaults to cwd."),
|
|
10
|
+
framework: z
|
|
11
|
+
.enum(["expo", "flutter"])
|
|
12
|
+
.optional()
|
|
13
|
+
.default("expo")
|
|
14
|
+
.describe("Project framework (default: expo)."),
|
|
15
|
+
default_locale: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.default("en")
|
|
19
|
+
.describe("Default locale code (default: en)."),
|
|
20
|
+
additional_locales: z
|
|
21
|
+
.array(z.string())
|
|
22
|
+
.optional()
|
|
23
|
+
.default([])
|
|
24
|
+
.describe("Additional locale codes to create placeholder files for (e.g. ['es', 'fr', 'de'])."),
|
|
25
|
+
};
|
|
26
|
+
function generateExpoI18nConfig(defaultLocale) {
|
|
27
|
+
return `import i18n from "i18next";
|
|
28
|
+
import { initReactI18next } from "react-i18next";
|
|
29
|
+
import { getLocales } from "expo-localization";
|
|
30
|
+
import ${defaultLocale} from "./${defaultLocale}.json";
|
|
31
|
+
|
|
32
|
+
const deviceLocale = getLocales()[0]?.languageCode ?? "${defaultLocale}";
|
|
33
|
+
|
|
34
|
+
i18n.use(initReactI18next).init({
|
|
35
|
+
resources: {
|
|
36
|
+
${defaultLocale}: { translation: ${defaultLocale} },
|
|
37
|
+
},
|
|
38
|
+
lng: deviceLocale,
|
|
39
|
+
fallbackLng: "${defaultLocale}",
|
|
40
|
+
interpolation: {
|
|
41
|
+
escapeValue: false,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default i18n;
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
function generateLocaleJson(locale) {
|
|
49
|
+
return JSON.stringify({
|
|
50
|
+
common: {
|
|
51
|
+
ok: locale === "en" ? "OK" : `[${locale}] OK`,
|
|
52
|
+
cancel: locale === "en" ? "Cancel" : `[${locale}] Cancel`,
|
|
53
|
+
save: locale === "en" ? "Save" : `[${locale}] Save`,
|
|
54
|
+
delete: locale === "en" ? "Delete" : `[${locale}] Delete`,
|
|
55
|
+
loading: locale === "en" ? "Loading..." : `[${locale}] Loading...`,
|
|
56
|
+
},
|
|
57
|
+
errors: {
|
|
58
|
+
generic: locale === "en" ? "Something went wrong" : `[${locale}] Something went wrong`,
|
|
59
|
+
network: locale === "en" ? "Check your internet connection" : `[${locale}] Check your internet connection`,
|
|
60
|
+
},
|
|
61
|
+
}, null, 2);
|
|
62
|
+
}
|
|
63
|
+
function generateFlutterL10nYaml(defaultLocale) {
|
|
64
|
+
return `arb-dir: lib/l10n
|
|
65
|
+
template-arb-file: app_${defaultLocale}.arb
|
|
66
|
+
output-localization-file: app_localizations.dart
|
|
67
|
+
output-class: AppLocalizations
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
function generateArbFile(locale) {
|
|
71
|
+
const data = {
|
|
72
|
+
"@@locale": locale,
|
|
73
|
+
ok: locale === "en" ? "OK" : `[${locale}] OK`,
|
|
74
|
+
"@ok": JSON.stringify({ description: "Generic OK button label" }),
|
|
75
|
+
cancel: locale === "en" ? "Cancel" : `[${locale}] Cancel`,
|
|
76
|
+
"@cancel": JSON.stringify({ description: "Generic Cancel button label" }),
|
|
77
|
+
save: locale === "en" ? "Save" : `[${locale}] Save`,
|
|
78
|
+
"@save": JSON.stringify({ description: "Generic Save button label" }),
|
|
79
|
+
errorGeneric: locale === "en" ? "Something went wrong" : `[${locale}] Something went wrong`,
|
|
80
|
+
"@errorGeneric": JSON.stringify({ description: "Generic error message" }),
|
|
81
|
+
};
|
|
82
|
+
return JSON.stringify(data, null, 2);
|
|
83
|
+
}
|
|
84
|
+
export function register(server) {
|
|
85
|
+
server.tool("mobile_setupI18n", "Initialize internationalization (i18n) config with locale files and translation structure. Supports i18next for Expo and flutter_localizations for Flutter.", inputSchema, async (args) => {
|
|
86
|
+
try {
|
|
87
|
+
const root = args.project_path || process.cwd();
|
|
88
|
+
const locales = [args.default_locale, ...args.additional_locales];
|
|
89
|
+
const filesCreated = [];
|
|
90
|
+
if (args.framework === "flutter") {
|
|
91
|
+
const l10nDir = join(root, "lib", "l10n");
|
|
92
|
+
mkdirSync(l10nDir, { recursive: true });
|
|
93
|
+
const l10nYamlPath = join(root, "l10n.yaml");
|
|
94
|
+
if (!existsSync(l10nYamlPath)) {
|
|
95
|
+
writeFileSync(l10nYamlPath, generateFlutterL10nYaml(args.default_locale), "utf-8");
|
|
96
|
+
filesCreated.push(l10nYamlPath);
|
|
97
|
+
}
|
|
98
|
+
for (const locale of locales) {
|
|
99
|
+
const arbPath = join(l10nDir, `app_${locale}.arb`);
|
|
100
|
+
if (!existsSync(arbPath)) {
|
|
101
|
+
writeFileSync(arbPath, generateArbFile(locale), "utf-8");
|
|
102
|
+
filesCreated.push(arbPath);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return textResponse(JSON.stringify({
|
|
106
|
+
success: true,
|
|
107
|
+
framework: "flutter",
|
|
108
|
+
files_created: filesCreated,
|
|
109
|
+
default_locale: args.default_locale,
|
|
110
|
+
locales,
|
|
111
|
+
next_steps: [
|
|
112
|
+
"Add flutter_localizations to pubspec.yaml dependencies",
|
|
113
|
+
"Add generate: true to pubspec.yaml",
|
|
114
|
+
"Import and add AppLocalizations.delegate to MaterialApp localizationsDelegates",
|
|
115
|
+
"Add AppLocalizations.supportedLocales to MaterialApp supportedLocales",
|
|
116
|
+
"Run flutter gen-l10n to generate the dart files",
|
|
117
|
+
"Use AppLocalizations.of(context)!.ok in your widgets",
|
|
118
|
+
],
|
|
119
|
+
}, null, 2));
|
|
120
|
+
}
|
|
121
|
+
const i18nDir = join(root, "i18n");
|
|
122
|
+
mkdirSync(i18nDir, { recursive: true });
|
|
123
|
+
for (const locale of locales) {
|
|
124
|
+
const localePath = join(i18nDir, `${locale}.json`);
|
|
125
|
+
if (!existsSync(localePath)) {
|
|
126
|
+
writeFileSync(localePath, generateLocaleJson(locale) + "\n", "utf-8");
|
|
127
|
+
filesCreated.push(localePath);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const configPath = join(i18nDir, "index.ts");
|
|
131
|
+
if (!existsSync(configPath)) {
|
|
132
|
+
writeFileSync(configPath, generateExpoI18nConfig(args.default_locale), "utf-8");
|
|
133
|
+
filesCreated.push(configPath);
|
|
134
|
+
}
|
|
135
|
+
return textResponse(JSON.stringify({
|
|
136
|
+
success: true,
|
|
137
|
+
framework: "expo",
|
|
138
|
+
files_created: filesCreated,
|
|
139
|
+
default_locale: args.default_locale,
|
|
140
|
+
locales,
|
|
141
|
+
next_steps: [
|
|
142
|
+
"Install dependencies: npx expo install i18next react-i18next expo-localization",
|
|
143
|
+
'Import i18n config in your app entry: import "./i18n"',
|
|
144
|
+
'Use translations: const { t } = useTranslation(); t("common.ok")',
|
|
145
|
+
"Add more locale files to i18n/ for each supported language",
|
|
146
|
+
"Consider i18next-parser for extracting strings from code",
|
|
147
|
+
],
|
|
148
|
+
}, null, 2));
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
return errorResponse(err);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=setupI18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupI18n.js","sourceRoot":"","sources":["../../src/tools/setupI18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,GAAG;IAClB,YAAY,EAAE,CAAC;SACZ,MAAM,E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