pabal-resource-mcp 1.5.10 → 1.6.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.
@@ -0,0 +1,397 @@
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 getKeywordResearchDir() {
55
+ return path.join(getAsoDataDir(), ".aso", "keywordResearch");
56
+ }
57
+ function getProductsDir() {
58
+ return path.join(getPublicDir(), "products");
59
+ }
60
+ function loadConfig() {
61
+ const configPath = path.join(
62
+ os.homedir(),
63
+ ".config",
64
+ "pabal-mcp",
65
+ "config.json"
66
+ );
67
+ if (!fs.existsSync(configPath)) {
68
+ return {};
69
+ }
70
+ try {
71
+ const configContent = fs.readFileSync(configPath, "utf-8");
72
+ return JSON.parse(configContent);
73
+ } catch {
74
+ return {};
75
+ }
76
+ }
77
+ function getGeminiApiKey() {
78
+ const config = loadConfig();
79
+ if (config.gemini?.apiKey) {
80
+ return config.gemini.apiKey;
81
+ }
82
+ const envKey = process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY;
83
+ if (envKey) {
84
+ return envKey;
85
+ }
86
+ throw new Error(
87
+ `Gemini API key not found. Set it in ~/.config/pabal-mcp/config.json under "gemini.apiKey" or use GEMINI_API_KEY environment variable.`
88
+ );
89
+ }
90
+
91
+ // src/utils/aso-converter.ts
92
+ import fs2 from "fs";
93
+ import path2 from "path";
94
+ function generateFullDescription(localeData, metadata = {}) {
95
+ const { aso, landing } = localeData;
96
+ const template = aso?.template;
97
+ if (!template) {
98
+ return "";
99
+ }
100
+ const landingFeatures = landing?.features?.items || [];
101
+ const landingScreenshots = landing?.screenshots?.images || [];
102
+ const keyHeading = template.keyFeaturesHeading || "Key Features";
103
+ const featuresHeading = template.featuresHeading || "Additional Features";
104
+ const parts = [template.intro];
105
+ if (landingFeatures.length > 0) {
106
+ parts.push(
107
+ "",
108
+ keyHeading,
109
+ "",
110
+ ...landingFeatures.map(
111
+ (feature) => [`\u25B6\uFE0E ${feature.title}`, feature.body || ""].filter(Boolean).join("\n")
112
+ )
113
+ );
114
+ }
115
+ if (landingScreenshots.length > 0) {
116
+ parts.push("", featuresHeading, "");
117
+ parts.push(
118
+ ...landingScreenshots.map(
119
+ (screenshot) => [`\u25B6\uFE0E ${screenshot.title}`, screenshot.description || ""].filter(Boolean).join("\n")
120
+ )
121
+ );
122
+ }
123
+ parts.push("", template.outro);
124
+ const includeSupport = template.includeSupportLinks ?? true;
125
+ if (includeSupport) {
126
+ const contactLines = [
127
+ metadata.instagram ? `Instagram: ${metadata.instagram}` : null,
128
+ metadata.contactEmail ? `Email: ${metadata.contactEmail}` : null,
129
+ metadata.termsUrl ? `- Terms of Use: ${metadata.termsUrl}` : null,
130
+ metadata.privacyUrl ? `- Privacy Policy: ${metadata.privacyUrl}` : null
131
+ ].filter((line) => line !== null);
132
+ if (contactLines.length > 0) {
133
+ parts.push("", "[Contact & Support]", "", ...contactLines);
134
+ }
135
+ }
136
+ return parts.join("\n");
137
+ }
138
+ function loadAsoFromConfig(slug) {
139
+ const productsDir = getProductsDir();
140
+ const configPath = path2.join(productsDir, slug, "config.json");
141
+ console.debug(`[loadAsoFromConfig] Looking for ${slug}:`);
142
+ console.debug(` - productsDir: ${productsDir}`);
143
+ console.debug(` - configPath: ${configPath}`);
144
+ console.debug(` - configPath exists: ${fs2.existsSync(configPath)}`);
145
+ if (!fs2.existsSync(configPath)) {
146
+ console.warn(`[loadAsoFromConfig] Config file not found at ${configPath}`);
147
+ return {};
148
+ }
149
+ try {
150
+ const configContent = fs2.readFileSync(configPath, "utf-8");
151
+ const config = JSON.parse(configContent);
152
+ const localesDir = path2.join(productsDir, slug, "locales");
153
+ console.debug(` - localesDir: ${localesDir}`);
154
+ console.debug(` - localesDir exists: ${fs2.existsSync(localesDir)}`);
155
+ if (!fs2.existsSync(localesDir)) {
156
+ console.warn(
157
+ `[loadAsoFromConfig] Locales directory not found at ${localesDir}`
158
+ );
159
+ return {};
160
+ }
161
+ const localeFiles = fs2.readdirSync(localesDir).filter((f) => f.endsWith(".json"));
162
+ const locales = {};
163
+ for (const file of localeFiles) {
164
+ const localeCode = file.replace(".json", "");
165
+ const localePath = path2.join(localesDir, file);
166
+ const localeContent = fs2.readFileSync(localePath, "utf-8");
167
+ locales[localeCode] = JSON.parse(localeContent);
168
+ }
169
+ console.debug(
170
+ ` - Found ${Object.keys(locales).length} locale file(s): ${Object.keys(
171
+ locales
172
+ ).join(", ")}`
173
+ );
174
+ if (Object.keys(locales).length === 0) {
175
+ console.warn(
176
+ `[loadAsoFromConfig] No locale files found in ${localesDir}`
177
+ );
178
+ }
179
+ const defaultLocale = config.content?.defaultLocale || DEFAULT_LOCALE;
180
+ const asoData = {};
181
+ if (config.packageName) {
182
+ const googlePlayLocales = {};
183
+ const metadata = config.metadata || {};
184
+ const screenshots = metadata.screenshots || {};
185
+ for (const [locale, localeData] of Object.entries(locales)) {
186
+ if (!isSupportedLocale(locale)) {
187
+ console.debug(
188
+ `Skipping locale ${locale} - not a valid unified locale`
189
+ );
190
+ continue;
191
+ }
192
+ if (!isGooglePlayLocale(locale)) {
193
+ console.debug(
194
+ `Skipping locale ${locale} - not supported by Google Play`
195
+ );
196
+ continue;
197
+ }
198
+ const aso = localeData.aso || {};
199
+ if (!aso || !aso.title && !aso.shortDescription) {
200
+ console.warn(
201
+ `Locale ${locale} has no ASO data (title or shortDescription)`
202
+ );
203
+ }
204
+ const screenshotsDir = path2.join(productsDir, slug, "screenshots", locale);
205
+ const hasScreenshots = fs2.existsSync(screenshotsDir);
206
+ const localeScreenshots = hasScreenshots ? {
207
+ phone: screenshots.phone?.map(
208
+ (p) => p.replace(/\/screenshots\/[^/]+\//, `/screenshots/${locale}/`)
209
+ ),
210
+ tablet: screenshots.tablet?.map(
211
+ (p) => p.replace(/\/screenshots\/[^/]+\//, `/screenshots/${locale}/`)
212
+ )
213
+ } : {
214
+ phone: void 0,
215
+ tablet: void 0
216
+ };
217
+ googlePlayLocales[locale] = {
218
+ title: aso.title || "",
219
+ shortDescription: aso.shortDescription || "",
220
+ fullDescription: generateFullDescription(localeData, metadata),
221
+ packageName: config.packageName,
222
+ defaultLanguage: locale,
223
+ screenshots: {
224
+ phone: localeScreenshots.phone || [],
225
+ tablet: localeScreenshots.tablet
226
+ },
227
+ contactEmail: metadata.contactEmail
228
+ };
229
+ }
230
+ const googleLocaleKeys = Object.keys(googlePlayLocales);
231
+ if (googleLocaleKeys.length > 0) {
232
+ const hasConfigDefault = isGooglePlayLocale(defaultLocale) && Boolean(googlePlayLocales[defaultLocale]);
233
+ const resolvedDefault = hasConfigDefault ? defaultLocale : googlePlayLocales[DEFAULT_LOCALE] ? DEFAULT_LOCALE : googleLocaleKeys[0];
234
+ asoData.googlePlay = {
235
+ locales: googlePlayLocales,
236
+ defaultLocale: resolvedDefault
237
+ };
238
+ }
239
+ }
240
+ if (config.bundleId) {
241
+ const appStoreLocales = {};
242
+ const metadata = config.metadata || {};
243
+ const screenshots = metadata.screenshots || {};
244
+ for (const [locale, localeData] of Object.entries(locales)) {
245
+ if (!isSupportedLocale(locale)) {
246
+ console.debug(
247
+ `Skipping locale ${locale} - not a valid unified locale`
248
+ );
249
+ continue;
250
+ }
251
+ if (!isAppStoreLocale(locale)) {
252
+ console.debug(
253
+ `Skipping locale ${locale} - not supported by App Store`
254
+ );
255
+ continue;
256
+ }
257
+ const aso = localeData.aso || {};
258
+ if (!aso || !aso.title && !aso.shortDescription) {
259
+ console.warn(
260
+ `Locale ${locale} has no ASO data (title or shortDescription)`
261
+ );
262
+ }
263
+ const screenshotsDir = path2.join(productsDir, slug, "screenshots", locale);
264
+ const hasScreenshots = fs2.existsSync(screenshotsDir);
265
+ const localeScreenshots = hasScreenshots ? {
266
+ phone: screenshots.phone?.map(
267
+ (p) => p.replace(/\/screenshots\/[^/]+\//, `/screenshots/${locale}/`)
268
+ ),
269
+ tablet: screenshots.tablet?.map(
270
+ (p) => p.replace(/\/screenshots\/[^/]+\//, `/screenshots/${locale}/`)
271
+ )
272
+ } : {
273
+ phone: void 0,
274
+ tablet: void 0
275
+ };
276
+ appStoreLocales[locale] = {
277
+ name: aso.title || "",
278
+ subtitle: aso.subtitle,
279
+ description: generateFullDescription(localeData, metadata),
280
+ keywords: Array.isArray(aso.keywords) ? aso.keywords.join(", ") : aso.keywords,
281
+ promotionalText: void 0,
282
+ bundleId: config.bundleId,
283
+ locale,
284
+ supportUrl: metadata.supportUrl,
285
+ marketingUrl: metadata.marketingUrl,
286
+ privacyPolicyUrl: metadata.privacyUrl,
287
+ termsUrl: metadata.termsUrl,
288
+ screenshots: {
289
+ // 폰 스크린샷을 iphone65로 매핑
290
+ iphone65: localeScreenshots.phone || [],
291
+ // 태블릿 스크린샷을 ipadPro129로 매핑
292
+ ipadPro129: localeScreenshots.tablet
293
+ }
294
+ };
295
+ }
296
+ const appStoreLocaleKeys = Object.keys(appStoreLocales);
297
+ if (appStoreLocaleKeys.length > 0) {
298
+ const hasConfigDefault = isAppStoreLocale(defaultLocale) && Boolean(appStoreLocales[defaultLocale]);
299
+ const resolvedDefault = hasConfigDefault ? defaultLocale : appStoreLocales[DEFAULT_LOCALE] ? DEFAULT_LOCALE : appStoreLocaleKeys[0];
300
+ asoData.appStore = {
301
+ locales: appStoreLocales,
302
+ defaultLocale: resolvedDefault
303
+ };
304
+ }
305
+ }
306
+ const hasGooglePlay = !!asoData.googlePlay;
307
+ const hasAppStore = !!asoData.appStore;
308
+ console.debug(`[loadAsoFromConfig] Result for ${slug}:`);
309
+ console.debug(
310
+ ` - Google Play data: ${hasGooglePlay ? "found" : "not found"}`
311
+ );
312
+ console.debug(` - App Store data: ${hasAppStore ? "found" : "not found"}`);
313
+ if (!hasGooglePlay && !hasAppStore) {
314
+ console.warn(`[loadAsoFromConfig] No ASO data generated for ${slug}`);
315
+ }
316
+ return asoData;
317
+ } catch (error) {
318
+ console.error(
319
+ `[loadAsoFromConfig] Failed to load ASO data from config for ${slug}:`,
320
+ error
321
+ );
322
+ return {};
323
+ }
324
+ }
325
+ function saveAsoToConfig(slug, config) {
326
+ const productsDir = getProductsDir();
327
+ const configPath = path2.join(productsDir, slug, "config.json");
328
+ fs2.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
329
+ }
330
+ function saveAsoToAsoDir(slug, asoData) {
331
+ const rootDir = getPushDataDir();
332
+ if (asoData.googlePlay) {
333
+ const asoPath = path2.join(
334
+ rootDir,
335
+ "products",
336
+ slug,
337
+ "store",
338
+ "google-play",
339
+ "aso-data.json"
340
+ );
341
+ const dir = path2.dirname(asoPath);
342
+ if (!fs2.existsSync(dir)) {
343
+ fs2.mkdirSync(dir, { recursive: true });
344
+ }
345
+ const googlePlayData = asoData.googlePlay;
346
+ const multilingualData = "locales" in googlePlayData ? googlePlayData : {
347
+ locales: {
348
+ [googlePlayData.defaultLanguage || DEFAULT_LOCALE]: googlePlayData
349
+ },
350
+ defaultLocale: googlePlayData.defaultLanguage || DEFAULT_LOCALE
351
+ };
352
+ fs2.writeFileSync(
353
+ asoPath,
354
+ JSON.stringify({ googlePlay: multilingualData }, null, 2) + "\n",
355
+ "utf-8"
356
+ );
357
+ }
358
+ if (asoData.appStore) {
359
+ const asoPath = path2.join(
360
+ rootDir,
361
+ "products",
362
+ slug,
363
+ "store",
364
+ "app-store",
365
+ "aso-data.json"
366
+ );
367
+ const dir = path2.dirname(asoPath);
368
+ if (!fs2.existsSync(dir)) {
369
+ fs2.mkdirSync(dir, { recursive: true });
370
+ }
371
+ const appStoreData = asoData.appStore;
372
+ const multilingualData = "locales" in appStoreData ? appStoreData : {
373
+ locales: {
374
+ [appStoreData.locale || DEFAULT_LOCALE]: appStoreData
375
+ },
376
+ defaultLocale: appStoreData.locale || DEFAULT_LOCALE
377
+ };
378
+ fs2.writeFileSync(
379
+ asoPath,
380
+ JSON.stringify({ appStore: multilingualData }, null, 2) + "\n",
381
+ "utf-8"
382
+ );
383
+ }
384
+ }
385
+
386
+ export {
387
+ getAsoDataDir,
388
+ getPullDataDir,
389
+ getPushDataDir,
390
+ getPublicDir,
391
+ getKeywordResearchDir,
392
+ getProductsDir,
393
+ getGeminiApiKey,
394
+ loadAsoFromConfig,
395
+ saveAsoToConfig,
396
+ saveAsoToAsoDir
397
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { w as AsoData, Z as ProductConfig } from './locale-converter-CcA-f2gI.js';
2
- export { A as APP_STORE_TO_UNIFIED, F as AppMetaLinks, H as AppPageData, t as AppStoreAsoData, p as AppStoreInfoLocalization, d as AppStoreLocale, v as AppStoreMultilingualAsoData, o as AppStoreReleaseNote, r as AppStoreScreenshotDisplayType, s as AppStoreScreenshots, q as AppStoreVersionLocalization, $ as AsoLocaleContent, _ as AsoTemplate, C as BlogArticle, z as BlogMeta, B as BlogMetaBlock, a4 as BlogMetaOutput, E as BlogSummary, a5 as CreateBlogHtmlInput, a7 as CreateBlogHtmlResult, D as DEFAULT_LOCALE, R as DeepPartial, M as FeatureItem, G as GOOGLE_PLAY_TO_UNIFIED, a6 as GeneratedBlogFile, m as GooglePlayAsoData, j as GooglePlayImageType, h as GooglePlayListing, e as GooglePlayLocale, u as GooglePlayMultilingualAsoData, n as GooglePlayReleaseNote, k as GooglePlayScreenshotType, l as GooglePlayScreenshots, I as ImageAsset, P as LandingCta, N as LandingFeatures, J as LandingHero, Q as LandingPage, V as LandingPageLocale, O as LandingReviews, K as LandingScreenshots, L as LayoutColors, a2 as LocaleDisplayInfo, Y as ProductContent, a0 as ProductLocale, X as ProductMetadata, W as ProductScreenshots, a1 as SiteConfig, a3 as SiteData, S as SupportedLocale, T as Testimonial, U as UNIFIED_LOCALES, a as UNIFIED_TO_APP_STORE, b as UNIFIED_TO_GOOGLE_PLAY, c as UnifiedLocale, ah as appStoreToGooglePlay, ab as appStoreToUnified, af as appStoreToUnifiedBatch, al as convertObjectFromAppStore, am as convertObjectFromGooglePlay, aj as convertObjectToAppStore, ak as convertObjectToGooglePlay, ai as googlePlayToAppStore, ac as googlePlayToUnified, ag as googlePlayToUnifiedBatch, f as isAppStoreLocale, y as isAppStoreMultilingual, g as isGooglePlayLocale, x as isGooglePlayMultilingual, i as isSupportedLocale, a8 as unifiedToAppStore, ad as unifiedToAppStoreBatch, aa as unifiedToBothPlatforms, a9 as unifiedToGooglePlay, ae as unifiedToGooglePlayBatch } from './locale-converter-CcA-f2gI.js';
1
+ import { w as AsoData, Z as ProductConfig } from './locale-converter-CHX8t4HG.js';
2
+ export { A as APP_STORE_TO_UNIFIED, F as AppMetaLinks, H as AppPageData, t as AppStoreAsoData, p as AppStoreInfoLocalization, d as AppStoreLocale, v as AppStoreMultilingualAsoData, o as AppStoreReleaseNote, r as AppStoreScreenshotDisplayType, s as AppStoreScreenshots, q as AppStoreVersionLocalization, $ as AsoLocaleContent, _ as AsoTemplate, C as BlogArticle, z as BlogMeta, B as BlogMetaBlock, a4 as BlogMetaOutput, E as BlogSummary, a5 as CreateBlogHtmlInput, a7 as CreateBlogHtmlResult, D as DEFAULT_LOCALE, R as DeepPartial, M as FeatureItem, G as GOOGLE_PLAY_TO_UNIFIED, a6 as GeneratedBlogFile, m as GooglePlayAsoData, j as GooglePlayImageType, h as GooglePlayListing, e as GooglePlayLocale, u as GooglePlayMultilingualAsoData, n as GooglePlayReleaseNote, k as GooglePlayScreenshotType, l as GooglePlayScreenshots, I as ImageAsset, P as LandingCta, N as LandingFeatures, J as LandingHero, Q as LandingPage, V as LandingPageLocale, O as LandingReviews, K as LandingScreenshots, L as LayoutColors, a2 as LocaleDisplayInfo, Y as ProductContent, a0 as ProductLocale, X as ProductMetadata, W as ProductScreenshots, a1 as SiteConfig, a3 as SiteData, S as SupportedLocale, T as Testimonial, U as UNIFIED_LOCALES, a as UNIFIED_TO_APP_STORE, b as UNIFIED_TO_GOOGLE_PLAY, c as UnifiedLocale, ah as appStoreToGooglePlay, ab as appStoreToUnified, af as appStoreToUnifiedBatch, al as convertObjectFromAppStore, am as convertObjectFromGooglePlay, aj as convertObjectToAppStore, ak as convertObjectToGooglePlay, ai as googlePlayToAppStore, ac as googlePlayToUnified, ag as googlePlayToUnifiedBatch, f as isAppStoreLocale, y as isAppStoreMultilingual, g as isGooglePlayLocale, x as isGooglePlayMultilingual, i as isSupportedLocale, a8 as unifiedToAppStore, ad as unifiedToAppStoreBatch, aa as unifiedToBothPlatforms, a9 as unifiedToGooglePlay, ae as unifiedToGooglePlayBatch } from './locale-converter-CHX8t4HG.js';
3
3
  import '@googleapis/androidpublisher';
4
4
  import 'appstore-connect-sdk/openapi';
5
5
 
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  loadAsoFromConfig,
10
10
  saveAsoToAsoDir,
11
11
  saveAsoToConfig
12
- } from "./chunk-AIFJ4O2O.js";
12
+ } from "./chunk-7BCPWAMQ.js";
13
13
  import {
14
14
  APP_STORE_TO_UNIFIED,
15
15
  DEFAULT_LOCALE,