pabal-web-mcp 1.2.3 → 1.2.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/bin/mcp-server.js +10 -8
- package/dist/browser.d.ts +15 -0
- package/dist/browser.js +60 -0
- package/dist/chunk-BOWRBVVV.js +716 -0
- package/dist/chunk-DLCIXAUB.js +6 -0
- package/dist/chunk-FXCHLO7O.js +351 -0
- package/dist/index.d.ts +5 -797
- package/dist/index.js +11 -9
- package/dist/locale-converter-B_NCFuS8.d.ts +798 -0
- package/package.json +12 -2
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LOCALE,
|
|
3
|
+
isAppStoreLocale,
|
|
4
|
+
isGooglePlayLocale,
|
|
5
|
+
isSupportedLocale
|
|
6
|
+
} from "./chunk-BOWRBVVV.js";
|
|
7
|
+
|
|
8
|
+
// src/utils/config.util.ts
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import os from "os";
|
|
12
|
+
function getAsoDataDir() {
|
|
13
|
+
const configPath = path.join(
|
|
14
|
+
os.homedir(),
|
|
15
|
+
".config",
|
|
16
|
+
"pabal-mcp",
|
|
17
|
+
"config.json"
|
|
18
|
+
);
|
|
19
|
+
if (!fs.existsSync(configPath)) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Config file not found at ${configPath}. Please create the config file and set the 'dataDir' property to specify the ASO data directory.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
26
|
+
const config = JSON.parse(configContent);
|
|
27
|
+
if (!config.dataDir) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`'dataDir' property is not set in ${configPath}. Please set 'dataDir' to specify the ASO data directory.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (path.isAbsolute(config.dataDir)) {
|
|
33
|
+
return config.dataDir;
|
|
34
|
+
}
|
|
35
|
+
return path.resolve(os.homedir(), config.dataDir);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof Error && error.message.includes("dataDir")) {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Failed to read config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function getPullDataDir() {
|
|
46
|
+
return path.join(getAsoDataDir(), ".aso", "pullData");
|
|
47
|
+
}
|
|
48
|
+
function getPushDataDir() {
|
|
49
|
+
return path.join(getAsoDataDir(), ".aso", "pushData");
|
|
50
|
+
}
|
|
51
|
+
function getPublicDir() {
|
|
52
|
+
return path.join(getAsoDataDir(), "public");
|
|
53
|
+
}
|
|
54
|
+
function getProductsDir() {
|
|
55
|
+
return path.join(getPublicDir(), "products");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/utils/aso-converter.ts
|
|
59
|
+
import fs2 from "fs";
|
|
60
|
+
import path2 from "path";
|
|
61
|
+
function generateFullDescription(localeData, metadata = {}) {
|
|
62
|
+
const { aso, landing } = localeData;
|
|
63
|
+
const template = aso?.template;
|
|
64
|
+
if (!template) {
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
const landingFeatures = landing?.features?.items || [];
|
|
68
|
+
const landingScreenshots = landing?.screenshots?.images || [];
|
|
69
|
+
const keyHeading = template.keyFeaturesHeading || "Key Features";
|
|
70
|
+
const featuresHeading = template.featuresHeading || "Additional Features";
|
|
71
|
+
const parts = [template.intro];
|
|
72
|
+
if (landingFeatures.length > 0) {
|
|
73
|
+
parts.push(
|
|
74
|
+
"",
|
|
75
|
+
keyHeading,
|
|
76
|
+
"",
|
|
77
|
+
...landingFeatures.map(
|
|
78
|
+
(feature) => [`\u25B6\uFE0E ${feature.title}`, feature.body || ""].filter(Boolean).join("\n")
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (landingScreenshots.length > 0) {
|
|
83
|
+
parts.push("", featuresHeading, "");
|
|
84
|
+
parts.push(
|
|
85
|
+
...landingScreenshots.map(
|
|
86
|
+
(screenshot) => [`\u25B6\uFE0E ${screenshot.title}`, screenshot.description || ""].filter(Boolean).join("\n")
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
parts.push("", template.outro);
|
|
91
|
+
const includeSupport = template.includeSupportLinks ?? true;
|
|
92
|
+
if (includeSupport) {
|
|
93
|
+
const contactLines = [
|
|
94
|
+
metadata.instagram ? `Instagram: ${metadata.instagram}` : null,
|
|
95
|
+
metadata.contactEmail ? `Email: ${metadata.contactEmail}` : null,
|
|
96
|
+
metadata.termsUrl ? `- Terms of Use: ${metadata.termsUrl}` : null,
|
|
97
|
+
metadata.privacyUrl ? `- Privacy Policy: ${metadata.privacyUrl}` : null
|
|
98
|
+
].filter((line) => line !== null);
|
|
99
|
+
if (contactLines.length > 0) {
|
|
100
|
+
parts.push("", "[Contact & Support]", "", ...contactLines);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return parts.join("\n");
|
|
104
|
+
}
|
|
105
|
+
function loadAsoFromConfig(slug) {
|
|
106
|
+
const productsDir = getProductsDir();
|
|
107
|
+
const configPath = path2.join(productsDir, slug, "config.json");
|
|
108
|
+
console.debug(`[loadAsoFromConfig] Looking for ${slug}:`);
|
|
109
|
+
console.debug(` - productsDir: ${productsDir}`);
|
|
110
|
+
console.debug(` - configPath: ${configPath}`);
|
|
111
|
+
console.debug(` - configPath exists: ${fs2.existsSync(configPath)}`);
|
|
112
|
+
if (!fs2.existsSync(configPath)) {
|
|
113
|
+
console.warn(`[loadAsoFromConfig] Config file not found at ${configPath}`);
|
|
114
|
+
return {};
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const configContent = fs2.readFileSync(configPath, "utf-8");
|
|
118
|
+
const config = JSON.parse(configContent);
|
|
119
|
+
const localesDir = path2.join(productsDir, slug, "locales");
|
|
120
|
+
console.debug(` - localesDir: ${localesDir}`);
|
|
121
|
+
console.debug(` - localesDir exists: ${fs2.existsSync(localesDir)}`);
|
|
122
|
+
if (!fs2.existsSync(localesDir)) {
|
|
123
|
+
console.warn(
|
|
124
|
+
`[loadAsoFromConfig] Locales directory not found at ${localesDir}`
|
|
125
|
+
);
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
const localeFiles = fs2.readdirSync(localesDir).filter((f) => f.endsWith(".json"));
|
|
129
|
+
const locales = {};
|
|
130
|
+
for (const file of localeFiles) {
|
|
131
|
+
const localeCode = file.replace(".json", "");
|
|
132
|
+
const localePath = path2.join(localesDir, file);
|
|
133
|
+
const localeContent = fs2.readFileSync(localePath, "utf-8");
|
|
134
|
+
locales[localeCode] = JSON.parse(localeContent);
|
|
135
|
+
}
|
|
136
|
+
console.debug(
|
|
137
|
+
` - Found ${Object.keys(locales).length} locale file(s): ${Object.keys(
|
|
138
|
+
locales
|
|
139
|
+
).join(", ")}`
|
|
140
|
+
);
|
|
141
|
+
if (Object.keys(locales).length === 0) {
|
|
142
|
+
console.warn(
|
|
143
|
+
`[loadAsoFromConfig] No locale files found in ${localesDir}`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const defaultLocale = config.content?.defaultLocale || DEFAULT_LOCALE;
|
|
147
|
+
const asoData = {};
|
|
148
|
+
if (config.packageName) {
|
|
149
|
+
const googlePlayLocales = {};
|
|
150
|
+
const metadata = config.metadata || {};
|
|
151
|
+
const screenshots = metadata.screenshots || {};
|
|
152
|
+
for (const [locale, localeData] of Object.entries(locales)) {
|
|
153
|
+
if (!isSupportedLocale(locale)) {
|
|
154
|
+
console.debug(
|
|
155
|
+
`Skipping locale ${locale} - not a valid unified locale`
|
|
156
|
+
);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (!isGooglePlayLocale(locale)) {
|
|
160
|
+
console.debug(
|
|
161
|
+
`Skipping locale ${locale} - not supported by Google Play`
|
|
162
|
+
);
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const aso = localeData.aso || {};
|
|
166
|
+
if (!aso || !aso.title && !aso.shortDescription) {
|
|
167
|
+
console.warn(
|
|
168
|
+
`Locale ${locale} has no ASO data (title or shortDescription)`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const localeScreenshots = {
|
|
172
|
+
phone: screenshots.phone?.map(
|
|
173
|
+
(p) => p.replace("/screenshots/", `/screenshots/${locale}/`)
|
|
174
|
+
),
|
|
175
|
+
tablet: screenshots.tablet?.map(
|
|
176
|
+
(p) => p.replace("/screenshots/", `/screenshots/${locale}/`)
|
|
177
|
+
)
|
|
178
|
+
};
|
|
179
|
+
googlePlayLocales[locale] = {
|
|
180
|
+
title: aso.title || "",
|
|
181
|
+
shortDescription: aso.shortDescription || "",
|
|
182
|
+
fullDescription: generateFullDescription(localeData, metadata),
|
|
183
|
+
packageName: config.packageName,
|
|
184
|
+
defaultLanguage: locale,
|
|
185
|
+
screenshots: {
|
|
186
|
+
phone: localeScreenshots.phone || [],
|
|
187
|
+
tablet: localeScreenshots.tablet
|
|
188
|
+
},
|
|
189
|
+
contactEmail: metadata.contactEmail
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const googleLocaleKeys = Object.keys(googlePlayLocales);
|
|
193
|
+
if (googleLocaleKeys.length > 0) {
|
|
194
|
+
const hasConfigDefault = isGooglePlayLocale(defaultLocale) && Boolean(googlePlayLocales[defaultLocale]);
|
|
195
|
+
const resolvedDefault = hasConfigDefault ? defaultLocale : googlePlayLocales[DEFAULT_LOCALE] ? DEFAULT_LOCALE : googleLocaleKeys[0];
|
|
196
|
+
asoData.googlePlay = {
|
|
197
|
+
locales: googlePlayLocales,
|
|
198
|
+
defaultLocale: resolvedDefault
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (config.bundleId) {
|
|
203
|
+
const appStoreLocales = {};
|
|
204
|
+
const metadata = config.metadata || {};
|
|
205
|
+
const screenshots = metadata.screenshots || {};
|
|
206
|
+
for (const [locale, localeData] of Object.entries(locales)) {
|
|
207
|
+
if (!isSupportedLocale(locale)) {
|
|
208
|
+
console.debug(
|
|
209
|
+
`Skipping locale ${locale} - not a valid unified locale`
|
|
210
|
+
);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (!isAppStoreLocale(locale)) {
|
|
214
|
+
console.debug(
|
|
215
|
+
`Skipping locale ${locale} - not supported by App Store`
|
|
216
|
+
);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const aso = localeData.aso || {};
|
|
220
|
+
if (!aso || !aso.title && !aso.shortDescription) {
|
|
221
|
+
console.warn(
|
|
222
|
+
`Locale ${locale} has no ASO data (title or shortDescription)`
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
const localeScreenshots = {
|
|
226
|
+
phone: screenshots.phone?.map(
|
|
227
|
+
(p) => p.replace("/screenshots/", `/screenshots/${locale}/`)
|
|
228
|
+
),
|
|
229
|
+
tablet: screenshots.tablet?.map(
|
|
230
|
+
(p) => p.replace("/screenshots/", `/screenshots/${locale}/`)
|
|
231
|
+
)
|
|
232
|
+
};
|
|
233
|
+
appStoreLocales[locale] = {
|
|
234
|
+
name: aso.title || "",
|
|
235
|
+
subtitle: aso.subtitle,
|
|
236
|
+
description: generateFullDescription(localeData, metadata),
|
|
237
|
+
keywords: Array.isArray(aso.keywords) ? aso.keywords.join(", ") : aso.keywords,
|
|
238
|
+
promotionalText: void 0,
|
|
239
|
+
bundleId: config.bundleId,
|
|
240
|
+
locale,
|
|
241
|
+
supportUrl: metadata.supportUrl,
|
|
242
|
+
marketingUrl: metadata.marketingUrl,
|
|
243
|
+
privacyPolicyUrl: metadata.privacyUrl,
|
|
244
|
+
screenshots: {
|
|
245
|
+
// 폰 스크린샷을 iphone65로 매핑
|
|
246
|
+
iphone65: localeScreenshots.phone || [],
|
|
247
|
+
// 태블릿 스크린샷을 ipadPro129로 매핑
|
|
248
|
+
ipadPro129: localeScreenshots.tablet
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const appStoreLocaleKeys = Object.keys(appStoreLocales);
|
|
253
|
+
if (appStoreLocaleKeys.length > 0) {
|
|
254
|
+
const hasConfigDefault = isAppStoreLocale(defaultLocale) && Boolean(appStoreLocales[defaultLocale]);
|
|
255
|
+
const resolvedDefault = hasConfigDefault ? defaultLocale : appStoreLocales[DEFAULT_LOCALE] ? DEFAULT_LOCALE : appStoreLocaleKeys[0];
|
|
256
|
+
asoData.appStore = {
|
|
257
|
+
locales: appStoreLocales,
|
|
258
|
+
defaultLocale: resolvedDefault
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const hasGooglePlay = !!asoData.googlePlay;
|
|
263
|
+
const hasAppStore = !!asoData.appStore;
|
|
264
|
+
console.debug(`[loadAsoFromConfig] Result for ${slug}:`);
|
|
265
|
+
console.debug(
|
|
266
|
+
` - Google Play data: ${hasGooglePlay ? "found" : "not found"}`
|
|
267
|
+
);
|
|
268
|
+
console.debug(` - App Store data: ${hasAppStore ? "found" : "not found"}`);
|
|
269
|
+
if (!hasGooglePlay && !hasAppStore) {
|
|
270
|
+
console.warn(`[loadAsoFromConfig] No ASO data generated for ${slug}`);
|
|
271
|
+
}
|
|
272
|
+
return asoData;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error(
|
|
275
|
+
`[loadAsoFromConfig] Failed to load ASO data from config for ${slug}:`,
|
|
276
|
+
error
|
|
277
|
+
);
|
|
278
|
+
return {};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function saveAsoToConfig(slug, config) {
|
|
282
|
+
const productsDir = getProductsDir();
|
|
283
|
+
const configPath = path2.join(productsDir, slug, "config.json");
|
|
284
|
+
fs2.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
285
|
+
}
|
|
286
|
+
function saveAsoToAsoDir(slug, asoData) {
|
|
287
|
+
const rootDir = getPushDataDir();
|
|
288
|
+
if (asoData.googlePlay) {
|
|
289
|
+
const asoPath = path2.join(
|
|
290
|
+
rootDir,
|
|
291
|
+
"products",
|
|
292
|
+
slug,
|
|
293
|
+
"store",
|
|
294
|
+
"google-play",
|
|
295
|
+
"aso-data.json"
|
|
296
|
+
);
|
|
297
|
+
const dir = path2.dirname(asoPath);
|
|
298
|
+
if (!fs2.existsSync(dir)) {
|
|
299
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
300
|
+
}
|
|
301
|
+
const googlePlayData = asoData.googlePlay;
|
|
302
|
+
const multilingualData = "locales" in googlePlayData ? googlePlayData : {
|
|
303
|
+
locales: {
|
|
304
|
+
[googlePlayData.defaultLanguage || DEFAULT_LOCALE]: googlePlayData
|
|
305
|
+
},
|
|
306
|
+
defaultLocale: googlePlayData.defaultLanguage || DEFAULT_LOCALE
|
|
307
|
+
};
|
|
308
|
+
fs2.writeFileSync(
|
|
309
|
+
asoPath,
|
|
310
|
+
JSON.stringify({ googlePlay: multilingualData }, null, 2) + "\n",
|
|
311
|
+
"utf-8"
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
if (asoData.appStore) {
|
|
315
|
+
const asoPath = path2.join(
|
|
316
|
+
rootDir,
|
|
317
|
+
"products",
|
|
318
|
+
slug,
|
|
319
|
+
"store",
|
|
320
|
+
"app-store",
|
|
321
|
+
"aso-data.json"
|
|
322
|
+
);
|
|
323
|
+
const dir = path2.dirname(asoPath);
|
|
324
|
+
if (!fs2.existsSync(dir)) {
|
|
325
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
326
|
+
}
|
|
327
|
+
const appStoreData = asoData.appStore;
|
|
328
|
+
const multilingualData = "locales" in appStoreData ? appStoreData : {
|
|
329
|
+
locales: {
|
|
330
|
+
[appStoreData.locale || DEFAULT_LOCALE]: appStoreData
|
|
331
|
+
},
|
|
332
|
+
defaultLocale: appStoreData.locale || DEFAULT_LOCALE
|
|
333
|
+
};
|
|
334
|
+
fs2.writeFileSync(
|
|
335
|
+
asoPath,
|
|
336
|
+
JSON.stringify({ appStore: multilingualData }, null, 2) + "\n",
|
|
337
|
+
"utf-8"
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export {
|
|
343
|
+
getAsoDataDir,
|
|
344
|
+
getPullDataDir,
|
|
345
|
+
getPushDataDir,
|
|
346
|
+
getPublicDir,
|
|
347
|
+
getProductsDir,
|
|
348
|
+
loadAsoFromConfig,
|
|
349
|
+
saveAsoToConfig,
|
|
350
|
+
saveAsoToAsoDir
|
|
351
|
+
};
|