UNPKG

wv-gotcha

Version:

![](https://raw.githubusercontent.com/wV-software/icons/main/Wv/Product%20Icon/wv_128x128.png) wv-local-service-bus # Purpose To accumulate your walkthroughs to accomplish your common tasks with less effort.

90 lines 5.37 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UTemplatePicker = void 0; const decova_filesystem_1 = require("decova-filesystem"); const temp_circuits_1 = require("temp-circuits"); const _Register_1 = require("temp-circuits/dist/Decorators/_Register"); const UPathMan_1 = require("../../UPathMan"); const wv_filesystem_1 = require("wv-filesystem"); const Mcq_PickGenTemplate_1 = require("../../Mcq_PickGenTemplate"); let UTemplatePicker = class UTemplatePicker extends temp_circuits_1.RootCircuit { promptTranslationMappingPicking() { return __awaiter(this, void 0, void 0, function* () { const genericGenMainDir = UPathMan_1.UPathMan.$().genericGenTemplates; const templateDirs = genericGenMainDir.GetDirectories() .xWhere(d => new decova_filesystem_1.FileInfo(wv_filesystem_1.Path.join(d.FullName, UPathMan_1.CommonFileName.translationMap)) .exists()); const translationMapFilePaths = templateDirs.xSelect(d => wv_filesystem_1.Path.join(d.FullName, UPathMan_1.CommonFileName.translationMap)); function loadTranslationMap(mapFilePath) { const map = require(mapFilePath); const templateDir = new decova_filesystem_1.FileInfo(mapFilePath).directory; const templatePath = templateDir.FullName; //#region set abs path for translation items for (const mapping of map.mappings) { mapping.templateDirName = templateDir.Name; // for(const translationItem of mapping.translationItems) // { // translationItem.absPath = Path.join(templatePath, translationItem.relativePath); // } } //#endregion return map; } const translationMaps = translationMapFilePaths.xSelect(path => loadTranslationMap(path)); const mcq = new Mcq_PickGenTemplate_1.Mcq_PickGenTemplate(translationMaps); const answer = yield mcq.selectAsync('Pick your template:'); return answer; // console.log(JSON.stringify(translationMaps)); // let absRootSrcDir = path.join(UPathMan.$().codeTemplatesDir.FullName, // srcRootDirPath) // .xReplaceAll('\\', '/'); // const filesToTranslate = // new DirectoryInfo(absRootSrcDir) // .GetDescendantFiles() // .xSelect(f => f.fullName) // .xWhere(f => toTranslateFileSelector(f)) // .xSelect(f => f.xReplaceAll('\\', '/')); // let count = 0; // for(let fPath of filesToTranslate) // { // const fSrcRelPath = fPath.xReplaceFirstOccurence(absRootSrcDir, ''); // let fDstAbsPath = path.join(UPathMan.$().currentDir.FullName, fSrcRelPath); // fDstAbsPath = fDstAbsPath.xReplaceAll('$$$', '.'); // fDstAbsPath = UTextTranslator.$().translate(fDstAbsPath, translationMap); // if(!overwrite && new FileInfo(fDstAbsPath).exists()) // { // Dialog.warning(`File skipped: ${fDstAbsPath}`); // continue; // } // Dialog.info(`Creating file: ${fDstAbsPath}`) // const contentToTranslate = new FileInfo(fPath).readAllText(); // const translatedContent = UTextTranslator.$().translate(contentToTranslate, translationMap); // const newFile = new FileInfo(fDstAbsPath); // newFile.directory.Ensure(); // newFile.writeAllText(translatedContent); // count ++; // } // return count; }); } }; exports.UTemplatePicker = UTemplatePicker; exports.UTemplatePicker = UTemplatePicker = __decorate([ (0, _Register_1.Register)() ], UTemplatePicker); //# sourceMappingURL=UTemplatePicker.js.map