"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; Object.defineProperty(exports, "__esModule", { value: true }); var fs = __importStar(require("fs")); var path_1 = require("path"); var crawl_1 = require("./tools/crawl"); var downloadAndUnzip_1 = require("./tools/downloadAndUnzip"); var download_sample_keycloak_themes_1 = require("./download-sample-keycloak-themes"); var getProjectRoot_1 = require("./tools/getProjectRoot"); var child_process = __importStar(require("child_process")); //@ts-ignore var propertiesParser = require("properties-parser"); console.log(propertiesParser); var tmpDirPath = path_1.join(getProjectRoot_1.getProjectRoot(), "tmp_xImOef9dOd44"); child_process.execSync("rm -rf " + tmpDirPath); downloadAndUnzip_1.downloadAndUnzip({ "destDirPath": tmpDirPath, "url": download_sample_keycloak_themes_1.keycloakBuiltinThemesAndThirdPartyExamplesThemsUrl }); var record = {}; process.chdir(path_1.join(tmpDirPath, "base")); crawl_1.crawl(".").forEach(function (filePath) { var _a; var match = filePath.match(/^([^/]+)\/messages\/messages_([^.]+)\.properties$/); if (match === null) { return; } var _b = __read(match, 3), typeOfPage = _b[1], language = _b[2]; ((_a = record[typeOfPage]) !== null && _a !== void 0 ? _a : (record[typeOfPage] = {}))[language] = propertiesParser.parse(fs.readFileSync(filePath) .toString("utf8")); }); child_process.execSync("rm -r " + tmpDirPath); var targetFilePath = path_1.join("src", "lib", "i18n", "messages.generated.ts"); fs.writeFileSync(path_1.join(getProjectRoot_1.getProjectRoot(), targetFilePath), Buffer.from([ "//This code was automatically generated by running " + path_1.relative(getProjectRoot_1.getProjectRoot(), __filename), '//PLEASE DO NOT EDIT MANUALLY', '', '/* spell-checker: disable */', "export const messages= " + JSON.stringify(record, null, 2) + " as const;", '/* spell-checker: enable */' ].join("\n"), "utf8")); console.log(targetFilePath + " wrote"); //# sourceMappingURL=generate-i18n-messages.js.map