wv-gotcha
Version:
 wv-local-service-bus # Purpose To accumulate your walkthroughs to accomplish your common tasks with less effort.
98 lines • 5.39 kB
JavaScript
;
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.WTR_GenericGen = void 0;
const decova_filesystem_1 = require("decova-filesystem");
const Dialog_1 = require("../Dialog");
const UTemplateTranslator_1 = require("../Libraries/TemplateTranslation/UTemplateTranslator");
const UPathMan_1 = require("../UPathMan");
const _RegisterWalkthrough_1 = require("./_Foundation/_RegisterWalkthrough");
const UTemplatePicker_1 = require("../Libraries/TemplateTranslation/UTemplatePicker");
const temp_circuits_1 = require("temp-circuits");
let WTR_GenericGen = class WTR_GenericGen {
constructor() {
this.text = 'Dev >> Generate ...';
}
execAsync() {
return __awaiter(this, void 0, void 0, function* () {
// #region prompt user for his target template mapping
const templatePicker = UTemplatePicker_1.UTemplatePicker.$();
const translationMapping = yield templatePicker.promptTranslationMappingPicking();
// #endregion
const templateDirName = translationMapping.templateDirName;
let count = 0;
function translateFileAsync(srcFileRelPath) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
for (const pattern of (_a = translationMapping.fileRelPathPatternsToIgnore) !== null && _a !== void 0 ? _a : []) {
try {
if (temp_circuits_1.Regex.parse(pattern).hasMatches(srcFileRelPath)) {
Dialog_1.Dialog.warning(`File '${srcFileRelPath}' skipped by 'fileRelPathPatternsToIgnore = '${pattern}'`);
return false;
}
}
catch (exp) {
Dialog_1.Dialog.error(`fileRelPathPatternsToIgnore = '${pattern}' is not a valid Regex pattern.`);
return false;
}
}
const isTranslated = yield UTemplateTranslator_1.UTemplateTranslator.$().translateGenericTemplateFileAsync(templateDirName, srcFileRelPath, []);
return isTranslated;
});
}
for (let translationItem of translationMapping.translationItems) {
switch (translationItem.itemType) {
case "file":
const srcFileRelPath = translationItem.relativePath;
const isTranslated = yield translateFileAsync(srcFileRelPath);
if (isTranslated)
count++;
break;
case "folder":
const folder = new decova_filesystem_1.DirectoryInfo(decova_filesystem_1.Path.join(UPathMan_1.UPathMan.$().contentDir.FullName));
if (folder.Exists() === false) {
Dialog_1.Dialog.error(`Folder '${translationItem.relativePath}' doesn't exist!`);
continue;
}
break;
}
}
if (count < 1) {
Dialog_1.Dialog.error('No files translated!');
}
else {
if (count > 1) {
Dialog_1.Dialog.success(`{${count}} Files have been created.`);
}
else {
Dialog_1.Dialog.success(`1 File has been created.`);
}
}
// const pathMan = UPathMan.$();
// if(new FileInfo(pathMan.dstnGitIgnoreFilePath).exists())
// {
// Dialog.warning(`${CommonFileName.gitIgnore} already exists`);
// return;
// }
});
}
};
WTR_GenericGen = __decorate([
(0, _RegisterWalkthrough_1.RegisterWalkthrough)()
], WTR_GenericGen);
exports.WTR_GenericGen = WTR_GenericGen;
//# sourceMappingURL=WTR_GenericGen.js.map