@forge/cli-shared

8.15.2-next.3-experimental-72ccdfa8.15.2-next.3-experimental-812ca41
~

Modified (5 files)

Index: package/out/service/i18n-resource-bundling-service.js
===================================================================
--- package/out/service/i18n-resource-bundling-service.js
+++ package/out/service/i18n-resource-bundling-service.js
@@ -23,10 +23,14 @@
             await fs_1.promises.copyFile(providedPath, dest);
         }));
     }
     async createI18nInfoFile(bundleDirPath, i18nConfig, modules) {
-        const i18nKeys = (0, i18n_1.extractI18nKeysFromModules)(modules);
+        const manifestKeys = (0, i18n_1.extractI18nKeysFromModules)(modules);
         const translationLookup = await this.loadTranslationLookup(i18nConfig);
+        const DYNAMIC_MODULE_I18N_PREFIX = 'dynamic.';
+        const allLocaleKeys = this.extractAllKeysFromTranslationLookup(translationLookup);
+        const dynamicKeys = allLocaleKeys.filter((key) => key.startsWith(DYNAMIC_MODULE_I18N_PREFIX));
+        const i18nKeys = [...new Set([...manifestKeys, ...dynamicKeys])].sort();
         const i18nInfo = this.createI18nInfo(i18nConfig, i18nKeys, translationLookup);
         const i18nInfoFilePath = (0, path_1.join)(bundleDirPath, i18n_1.I18N_INFO_FILE_NAME);
         await fs_1.promises.writeFile(i18nInfoFilePath, JSON.stringify(i18nInfo));
     }
@@ -65,8 +69,31 @@
             return [key, JSON.parse(file.toString())];
         }));
         return Object.fromEntries(results);
     }
+    extractAllKeysFromTranslationLookup(translationLookup) {
+        const allKeys = new Set();
+        const extractKeys = (obj, prefix = '') => {
+            if (!obj || typeof obj !== 'object') {
+                return;
+            }
+            for (const [key, value] of Object.entries(obj)) {
+                const fullKey = prefix ? `${prefix}.${key}` : key;
+                if (typeof value === 'string') {
+                    allKeys.add(fullKey);
+                }
+                else if (typeof value === 'object' && value !== null) {
+                    extractKeys(value, fullKey);
+                }
+            }
+        };
+        for (const localeTranslations of Object.values(translationLookup)) {
+            if (localeTranslations && typeof localeTranslations === 'object') {
+                extractKeys(localeTranslations);
+            }
+        }
+        return Array.from(allKeys);
+    }
     async bundle(modules, i18nConfig) {
         if (!modules || !i18nConfig) {
             return exports.EMPTY_I18N_RESOURCE_BUNDLE;
         }
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
 {
   "name": "@forge/cli-shared",
-  "version": "8.15.2-next.3-experimental-72ccdfa",
+  "version": "8.15.2-next.3-experimental-812ca41",
   "description": "Common functionality for Forge CLI",
   "author": "Atlassian",
   "license": "SEE LICENSE IN LICENSE.txt",
   "main": "out/index.js",
@@ -11,9 +11,9 @@
     "compile": "tsc -b -v",
     "generate-graphql-types": "graphql-codegen --config src/graphql/codegen.yml"
   },
   "dependencies": {
-    "@forge/manifest": "12.1.1-next.1-experimental-72ccdfa",
+    "@forge/manifest": "12.1.1-next.1-experimental-812ca41",
     "@forge/util": "2.0.1",
     "@forge/i18n": "0.0.7",
     "@sentry/node": "7.106.0",
     "adm-zip": "^0.5.10",
Index: package/out/service/i18n-resource-bundling-service.d.ts.map
===================================================================
--- package/out/service/i18n-resource-bundling-service.d.ts.map
+++ package/out/service/i18n-resource-bundling-service.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"i18n-resource-bundling-service.d.ts","sourceRoot":"","sources":["../../src/service/i18n-resource-bundling-service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOjG,oBAAY,kBAAkB,GAC1B;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;CACd,GACD;IACE,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEN,eAAO,MAAM,0BAA0B,EAAE,kBAAsC,CAAC;AAIhF,aAAK,wBAAwB,GAAG,CAAC,WAAW,EAAE,wBAAwB,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE3G,eAAO,MAAM,6BAA6B,uBAAwB,kBAAkB,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAMtG,CAAC;AAEF,qBAAa,2BAA2B;YACxB,0BAA0B;YAU1B,kBAAkB;IAUhC,OAAO,CAAC,cAAc;YAgCR,qBAAqB;IActB,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWvF,kBAAkB,CAAC,UAAU,EAAE,YAAY,GAAG,wBAAwB;CAuB9E"}
\ No newline at end of file
+{"version":3,"file":"i18n-resource-bundling-service.d.ts","sourceRoot":"","sources":["../../src/service/i18n-resource-bundling-service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOjG,oBAAY,kBAAkB,GAC1B;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;CACd,GACD;IACE,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEN,eAAO,MAAM,0BAA0B,EAAE,kBAAsC,CAAC;AAIhF,aAAK,wBAAwB,GAAG,CAAC,WAAW,EAAE,wBAAwB,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE3G,eAAO,MAAM,6BAA6B,uBAAwB,kBAAkB,KAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAMtG,CAAC;AAEF,qBAAa,2BAA2B;YACxB,0BAA0B;YAU1B,kBAAkB;IAkBhC,OAAO,CAAC,cAAc;YAgCR,qBAAqB;IAmBnC,OAAO,CAAC,mCAAmC;IAgC9B,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWvF,kBAAkB,CAAC,UAAU,EAAE,YAAY,GAAG,wBAAwB;CAuB9E"}
\ No newline at end of file
File too large for inline diff
Index: package/out/service/i18n-resource-bundling-service.d.ts
===================================================================
--- package/out/service/i18n-resource-bundling-service.d.ts
+++ package/out/service/i18n-resource-bundling-service.d.ts
@@ -14,8 +14,9 @@
     private copyLocaleFilesToBundleDir;
     private createI18nInfoFile;
     private createI18nInfo;
     private loadTranslationLookup;
+    private extractAllKeysFromTranslationLookup;
     bundle(modules?: Modules, i18nConfig?: Translations): Promise<I18nResourceBundle>;
     createFileAccessor(i18nConfig: Translations): I18nResourceFileAccessor;
 }
 export {};